Martyn Ball Martyn Ball - 6 days ago 5
jQuery Question

List event listeners of element

Trying to list the event listeners on a website with the following code:

$( document ).ready(function() {
var s = $._data($('.group4.cboxElement')[0], "events")
console.log(s);
});


However getting
Undefined
on the
console.log()
line.

This is the website, I need to see what event listeners are attached to the
<a>
links in the Gallery tab.

Edit:
Can someone tell me how to listen the events attached, or remove them that would be great.

Browser: Chrome

Answer

There's no official API for doing this.

If your goal is just to do this as part of debugging, Chrome itself can show you the event listeners attached to an element at the DOM level, see this question and its answers, and there are Chrome extensions (like this one) that can show you the jQuery event handlers as well (since jQuery maintains its own list of handlers, using only a single handler per event per element).