I'm wondering if it is possible to view
1. How many event listeners
2. What type of event listener
On a single web page.
Reason being is because I'm using off();
method.
I'm using this framework, which is basically jQuery but not.
Yeah, I'm using off but the even't isn't removing and and I have a feeling there is more than one eventListener
on the element.
If it is not possible with Javascript, it is possible in the browser?
Right-click on the search icon button and choose “inspect” to open the Chrome developer tools. Once the dev tools are open, switch to the “Event Listeners” tab and you will see all the event listeners bound to the element. You can expand any event listener by clicking the right-pointing arrowhead.
To check if an element has event listener on it with JavaScript, we can call the getEventListeners function in the Chrome developer console. getEventListeners(document. querySelector("your-element-selector")); in the Chrome developer console to select the element we want to check with querySelector .
Its stored in the actual list (array) of Event listeners for body . Elements have a list of function references in them for their event listeners. These references are not in the DOM. When firing an event, the browser has to run thru all the appropriate elements looking for these references and running them in order.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With