admin管理员组

文章数量:1322167

for example I have button element, the click event is attached to id in XXX.js file (I don't know the file name) , and I have many .js files. I want to debug the button click but how can I figure out where to set breakpoint if i don't know where button click function is ? is there any way to set breakpoint on element ( I'm using firebug, if it's impossible on firebug and possible for any other add-on please tell)

I'm using EXT sencha to add eventhandlers

for example I have button element, the click event is attached to id in XXX.js file (I don't know the file name) , and I have many .js files. I want to debug the button click but how can I figure out where to set breakpoint if i don't know where button click function is ? is there any way to set breakpoint on element ( I'm using firebug, if it's impossible on firebug and possible for any other add-on please tell)

I'm using EXT sencha to add eventhandlers

Share Improve this question edited Dec 24, 2013 at 16:46 luka asked Dec 24, 2013 at 16:27 lukaluka 1012 silver badges6 bronze badges 2
  • How are you attaching a click handler? With jQuery, addEventListener, attachEvent? Chrome's developer tools will show you events bount to the element. jQuery keep an internal reference for binding as well. – Sampson Commented Dec 24, 2013 at 16:30
  • Check out the answer to this question: stackoverflow./questions/11065358/… – Carmax Commented Dec 24, 2013 at 16:32
Add a ment  | 

5 Answers 5

Reset to default 2

Events handled with addEventListener:

Using your browser's developer tools, you can often times inspect an element to see what events are bound to it, and from which source file. For instance, the following example shows a click event bound to my button element:

Events handled with jQuery's $.fn.on:

If you bound the handler using jQuery's $.fn.on method, you can look into its internal $._data collection to determine what events handled for which elements:

I would check out this plugin. That will help you find what file/where the bound event lives. Then you can debug from there. http://www.sprymedia.co.uk/article/Visual+Event+2

If you want to know the js file with the listener, use Chrome dev tool, Inspect Element > On the Event Listeners you will find attached listeners and the file and even highlight the code on clicking. I don't know if this feature is in firebug too

Chrome Development Tools provides an Event Listener, which shows you elements and the attached Js-Events. Not quite sure if it helps you with your specific problem.

Firebug implements the getEventListeners mand that returns every event listeners for every events for a node:

http://www.softwareishard./blog/planet-mozilla/firebug-tip-geteventlisteners-mand/

Also there is the EventBug extension, that offers a UI:

https://getfirebug./wiki/index.php/Firebug_Extensions#Eventbug

本文标签: javascriptset breakpoint to html elementStack Overflow