开发者

How can I know a button's event handler in a html page? [duplicate]

This question already has answers here: Closed 11 years ago.

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:

How can I know a button's event handler in a html page? [duplicate]


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜