How to set a JavaScript breakpoint from code in Chrome?
我想强制Chrome调试器通过代码断行,或者使用某种类型的评论标记,如console.break() 。
You can use debugger; within your code. If the developer console is open, execution will break. It works in firebug as well.
Set up a button click listener and call the debugger;
Example
$("#myBtn").click(function() {
debugger;
});
Demo
http://jsfiddle.net/hBCH5/
Resources on debugging in JavaScript
As other have already said, debugger; is the way to go. I wrote a small script that you can use from the command line in a browser to set and remove breakpoint right before function call: http://andrijac.github.io/blog/2014/01/31/javascript-breakpoint/
