View event listeners - Javascript

丶灬走出姿态 提交于 2019-12-03 11:16:49

Chrome has some built in tools. If you open up the element inspector, focus on an element, scroll to the bottom of the right hand column (where the CSS/Metrics/etc are), you should see a drop down section that says Event Listeners. This can help some...

Often I find it easier to just add event listeners to some DOM element via the console and seeing if it responds. Or I throw in debuggers in various places (before setting up the listener, and inside the listener's callback). The problems I usually run into is the selector I think exists doesn't or the event gets bound too early and misses the selector.

A long time passes...

I have found something new in Chrome DevTools.

Simple as this in the console

getEventListeners(yourElement);

Documentation: https://developers.google.com/chrome-developer-tools

You can use the Visual Event bookmarklet: http://www.sprymedia.co.uk/article/Visual+Event+2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!