Is there any way to see what events are bound to an element with jQuery?
Asked
Active
Viewed 1.3k times
3 Answers
29
If you are using Safari or Chrome, you can open up the Developer Tools
and inspect the element (by clicking the magnifying glass). In the Event Listeners
tab on the right it will tell you the binded events to that element, with their functions and locations.
OR to do this via code:
$('selector').data('events'); // get
console.dir($('selector').data('events')); // display in firefox firebug or webkit's developer tools

balupton
- 47,113
- 32
- 131
- 182
-
1I've updated my question to include a code example to see the attached events. – balupton Jul 20 '10 at 08:45
-
The developer tools from Chrome does it display the events binded with jQuery? – Adrian Crapciu Jul 20 '10 at 08:54
-
Yep. Here is a screenshot: http://img830.imageshack.us/img830/1372/tmpu.png I've also included in my answer how to fetch the listeners using javascript, so you don't need to use a browser console. – balupton Jul 20 '10 at 09:11
-
@Adrian - Make sure to accept this as the answer if it answered your question via the checkmark on the left :) – Nick Craver Jul 20 '10 at 09:56
-
4This just isn't working for me. I'm only getting undefined returned when I call .data('events') on elements that clearly have events assigned to them. Any idea what could be wrong?? – Ryan Delucchi Mar 08 '11 at 21:47
-
Ryan ask it in a new question and attach a link here :) – balupton Mar 08 '11 at 23:59
8
This solution is obsolete in new jQuery versions. You must use:
$._data($('selector')[0],'events')

Rodrigo Perez Burgues
- 238
- 4
- 4
0
If you don't need this in script, you can check that element in any DOM inspection tool like Firebug and see all events.

Māris Kiseļovs
- 16,957
- 5
- 41
- 48
-
with Firebug can you also see what events are bound with jQuery? – Adrian Crapciu Jul 20 '10 at 09:15
-
Yes, and with anything other. Also you can do the same with Chrome/Safari/Opera Developer Tools. – Māris Kiseļovs Jul 20 '10 at 09:22
-
I must be blind but I can't find the Event Listener tab in Firebug. I use Firebug 1.5.4 and Firequery. – Adrian Crapciu Jul 20 '10 at 09:41
-
Then you can check this discussion - http://stackoverflow.com/questions/570960/how-to-debug-javascript-jquery-event-bindings-with-firebug-or-similar-tool – Māris Kiseļovs Jul 20 '10 at 09:48
-
it seems that the Events Panel is added from Firefox 3.7a1pre not in Firefox 3.6.* – Adrian Crapciu Jul 20 '10 at 13:37