Chrome breakpoint on radio doesn't fire

2019-07-10 03:30发布

问题:

I have a page where some JavaScript modifies a radio button to be not checked and another to be checked -- the HTML source contains the right checked attributes but when inspecting, the wrong one is checked. Also, when loading with JS off, the right one is checked. So I put a Chrome breakpoint on both for attribute modification and the breakpoints do not fire when reloading. I tried to set a breakpoint on a common parent div and it still doesn't fire.

回答1:

Phil's comment is helpful but it needs just a little love. First, check the Async checkbox

in the Sources tab just next to the Call Stack. Otherwise you won't get a useful call stack. Then add this snippet:

<script>
var debugel  = document.getElementById("edit-field-slideshow-media-type-und-images");
Object.observe(debugel, function(changes) {
  console.log(changes);
  debugger;
});
</script>

Between the console and the debugger you have a reasonable chance to figure out what happens.