Find which listener handles an event in DevTools
See every handler on an element and open its source in Chrome DevTools using the Event Listeners tab, including delegated handlers from ancestors.
A click on a button does something, and you cannot tell which function handles it. The Elements panel lists the listeners attached to the selected element.
<ul id="menu">
<li><button id="save">Save</button></li>
</ul>
<script>
document.querySelector("#menu").addEventListener("click", function onMenuClick(e) {
if (e.target.id === "save") console.log("saving");
});
</script>Select the button and open the Event Listeners tab in the side pane. By default it shows only listeners on the node itself, so the list may be empty here, because the handler lives on the ul element. Tick Ancestors to include handlers from parents, which is the delegation case:
click
ul#menu script.html:4Click the file link, and the Sources panel opens at the handler. Event delegation is why the listener is on a parent. The tab is documented in the DevTools Elements reference.
Frameworks register their own listeners, which can bury yours. Untick Framework listeners to hide the ones that DevTools can identify as library code.