admin管理员组文章数量:1322667
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
5 Answers
Reset to default 2Events 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
版权声明:本文标题:javascript - set breakpoint to html element? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742116810a2421506.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论