How to set a JavaScript breakpoint from code in Chrome?
You can use debugger;
within your code. If the developer console is open, execution will break. It works in firebug as well.
You can also use debug(function)
, to break when function
is called.
Set up a button click listener and call the debugger;
Example
$("#myBtn").click(function() { debugger; });
Demo
Resources on debugging in JavaScript