Problem

Say you want to find all the event listeners attached to a DOM node. How do you go about it?

Solution 1: Google Chrome

This solution will work only on Google Chrome or Chromium-based browsers.

We are going to use this website as an example.

Let's say you wanted to find all the event listeners attached to the search icon DOM element.

Picture of the author

Right-click on the search icon button and choose "inspect" to open the Chrome developer tools.

Picture of the author

Once the dev tools are open, switch to the "Event Listeners" tab and you will see all the event listeners bound to the element.

Picture of the author

You can expand any event listener by clicking the right-pointing arrowhead.

When you expand an event listener and hover over the element, the "remove" button will appear. It can be used to delete the event listener.

Picture of the author

Clicking on the filename main.min.js:6 takes you directly to the event listener callback function source by automatically switching you to the "sources" tab.

Picture of the author

As you can see in the screenshot below, you have been taken to the exact location of the event listener callback function.

Picture of the author

We can't see the event listener code properly right now since the code is minified.

Click on the {} icon to format the code.

Picture of the author

Solution 2: Firefox

Open Firefox.

Let's say you wanted to find all the event listeners attached to the search icon DOM element on this website.

Picture of the author

Right-click on the search icon button and choose "inspect" to open Firefox developer tools.

Picture of the author

The "search icon" button DOM node will be automatically highlighted in the Firefox "Inspector" tab.

Picture of the author

Click on the word "event" on the highlighted DOM node to see all the events bound to the element.

Picture of the author

Click on the right-pointing arrowhead to expand the event listener. You will be shown the source code for the event listener.

Picture of the author