Poss开发者_开发问答ible Duplicate:
How to debug Javascript/jQuery event bindings with FireBug (or similar tool) How to inspect an element's associated event handlers?
Sometimes,I use firebug to inspect a button in page, I found there is no onclick function. But actually it did have an event handler. I think it used "bind" method to attach event handler.
Now, my question is how can I use some tool and I can find out the event handler easily?
In google chrome it's really easy. There you can setup debuger so that it will stop execution whenever click event is fired:
I have a trick which could help you find what is triggered when you click on a button :
- use chrome (might have similar option in safari or even in firefox using firebug but I don't know)
- open the page you want to inspect (obviously :) ) and inspect anything in the page (right click, inspect this element)
- go to the scripts tab
- and click on the pause button (on right pane) and then click on your button
- the code is now breakpointed where the js is triggered (you can then follow the flow and debug your code)
精彩评论