Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View event listeners - Javascript

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?

like image 406
iConnor Avatar asked Jul 22 '13 18:07

iConnor


People also ask

How do you show event listeners?

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.

How do you check if an element already has an event listener JavaScript?

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 .

Where are event listeners stored JavaScript?

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.


1 Answers

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

like image 88
iConnor Avatar answered Sep 30 '22 13:09

iConnor