How to find event listeners on a DOM node in JavaScript or in debugging?
回答1
Chrome, Firefox, Vivaldi and Safari support getEventListeners(domElement)
in their Developer Tools console.
For majority of the debugging purposes, this could be used.
Below is a very good reference to use it:
getEventListeners function
Highly voted tip from Clifford Fajardo from the comments:
getEventListeners($0)
will get the event listeners for the element you have focused on in the Chrome dev tools.
getEventListeners($0)
will get the event listeners for the element you have focused on in the Chrome dev tools. I use this all the time. Love not having to use querySelector or get__By_ functions
– Clifford Fajardo
Jan 31, 2017 at 23:46
回答2
Update 2022:
In the Chrome Developer Tools
, in the Elements panel
, there is the Event Listeners
tab, where you can see listeners for the element.
You can also unselect "Ancestors" so it only shows the listeners for that element
标签:node,debugging,getEventListeners,DOM,Chrome,element,listeners,event From: https://www.cnblogs.com/chucklu/p/16908479.html