Martyn Ball
Martyn Ball

Reputation: 4885

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

Upvotes: 1

Views: 6935

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074138

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).

Upvotes: 4

Related Questions