Take the 2-minute tour ×

I need to find which event handlers are registered over an object.

For example:

$("#el").click(function() {...});
$("#el").mouseover(function() {...});

$("#el") has click and mouseover registered.

Is there a function to find out that, and possibly iterate over the event handlers?

If it is not possible on a jQuery object through proper methods, is it possible on a plain DOM object?

share|improve this question
unfortunately, now: bugs.jquery.com/ticket/10589 –  Skylar Saveland Aug 17 '12 at 18:52
add comment

7 Answers

up vote 226 down vote accepted

As of jQuery 1.8, the event data is no longer available from the "public API" for data. Read this jQuery blog post. You should now use this instead:

jQuery._data( elem, "events" );

elem should be an HTML Element, not a jQuery object, or selector.

Please note, that this is an internal, 'private' structure, and shouldn't be modified. Use this for debugging purposes only.

In older versions of jQuery, you might have to use the old method which is:

jQuery( elem ).data( "events" );
share|improve this answer
it's gone now: bugs.jquery.com/ticket/10589 –  Skylar Saveland Aug 17 '12 at 18:21
but you can still use $._data($(elem).get(0), "events") –  bullgare Aug 18 '12 at 11:01
blog.jquery.com/2011/11/08/building-a-slimmer-jquery .data(“events”): jQuery stores its event-related data in a data object named (wait for it) events on each element. This is an internal data structure so in 1.8 this will be removed from the user data name space so it won’t conflict with items of the same name. jQuery’s event data can still be accessed via jQuery._data(element, "events") but be aware that this is an internal data structure that is undocumented and should not be modified. –  Sam Greenhalgh Aug 20 '12 at 3:41
This is no longer valid. As of 1.9 this has been removed. –  oligofren Apr 3 '13 at 8:33
Really? It's working for me with 1.10/2.0 for me. –  podperson Jul 24 '13 at 19:40
show 3 more comments

You can do it like this:

$("#el").click(function(){ alert("click");});
$("#el").mouseover(function(){ alert("mouseover"); });

$.each($("#el").data("events"), function(i, e) {
//alerts 'click' then 'mouseover'

If you're on jQuery 1.4+, this will alert the event and functions bound to it:

$.each($("#el").data("events"), function(i, event) {
    $.each(event, function(j, h) {
//'function (){ alert("click"); }'
//'function(){ alert("mouseover"); }'

​You can play with it on jsFiddle here

share|improve this answer
This is the correct answer. The crucial bit is the second half. This helped me find an issue in under a minute that would have taken over an hour if I had to search through all the code. Thank you! –  Andrew Dec 29 '10 at 19:58
Works with 1.4, but not in jQuery 1.8.2. –  Timo Dec 21 '12 at 21:15
For jQuery 1.8+, you must use the 'private data' method: jQuery._data( jQuery("#el")[0], "events" ); instead of the 'public data' method: jQuery("#el").data("events"). The events object hasn't actually been stored in .data() for a long time, we trimmed a few bytes of code out by removing this "proxy" from the "public API" –  gnarf Jan 10 '13 at 17:13
add comment

For jQuery 1.8+, this will no longer work because the internal data is placed in a different object.

The latest unofficial (but works in previous versions as well, at least in 1.7.2) way of doing it now is - $._data(element, "events")

The underscore ("_") is what makes the difference here. Internally, it is calling $.data(element, name, null, true), the last (fourth) parameter is an internal one ("pvt").

share|improve this answer
$._data("body", "events") undefined $().jquery; "1.7.1" (tried 1.7.2 and 1.8.1 all the time "undefined") –  Michal Stefanow Sep 12 '12 at 12:02
@Michal - api.jquery.com/jQuery.data says it accepts an element, not a selector. –  PhistucK Sep 12 '12 at 15:08
Now works fine: $._data($("body").get(0), "events") Or even better: $("body").data("events") ! –  Michal Stefanow Sep 13 '12 at 11:12
FWIW - Pointing out that it 'internally' calls the other data function with a parameter we specifically don't document probably isn't needed. But yes, jQuery._data( element, "events" ) is the 'correct' way to get this information now. –  gnarf Jan 10 '13 at 17:11
add comment

I use eventbug plugin to firebug for this purpose.

share|improve this answer
Thanks, great tip. The extension adds a tab to Firebug ("Events") that shows the events of the page, so you can expore them easily. –  Gruber Feb 26 '13 at 8:17
Also, Chrome Developer Tools has "Event Listeners" under the "Elements" tab and "Event Listener Breakpoints" under the "Sources" tab. –  clayzermk1 Feb 27 '13 at 18:49
add comment

As of 1.9 there is no documented way to retrieve the events, other than to use the Migrate plugin to restore the old behavior. You could use the _.data() method as jps mentions, but that is an internal method. So just do the right thing and use the Migrate plugin if you need this functionality.

From the jQuery documentation on .data("events")

Prior to 1.9, .data("events") could be used to retrieve jQuery's undocumented internal event data structure for an element if no other code had defined a data element with the name "events". This special case has been removed in 1.9. There is no public interface to retrieve this internal data structure, and it remains undocumented. However, the jQuery Migrate plugin restores this behavior for code that depends upon it.

share|improve this answer
The accepted answer also clearly shows the new, correct way to get it for recent versions: jQuery._data( elem, "events" );... –  Ian May 23 '13 at 21:21
A private, undocumented way will never be a correct way. The correct way - meaning documented, public, and intended - is to use the Migrate plugin. –  oligofren May 27 '13 at 9:49
You seem to misunderstand the point of the Migrate plugin. jQuery removed deprecated features, and the Migrate plugin is to help migrate developer's code to the newer versions so that they can immediately take advantage of new features and improvements, but not lose functionality. It's meant to help the coder see what they need to do in order to start properly using new versions of jQuery. You shouldn't use it in production to restore features. Also, many things aren't documented and up to date in jQuery documentation - they've pointed it out before, so that's not a reason –  Ian May 28 '13 at 15:17
Also, if it's included as a suggestion in the jQuery blog, I'd use it: blog.jquery.com/2012/08/09/jquery-1-8-released –  Ian May 28 '13 at 15:17
Your reasoning on the Migrate plugin seems reasonable. OK if I delete my answer? –  oligofren May 28 '13 at 15:41
show 1 more comment

Shameless plug, but you can use findHandlerJS

To use it you just have to include findHandlersJS (or just copy&paste the raw javascript code to chrome's console window) and specify the event type and a jquery selector for the elements you are interested in.

For your example you could quickly find the event handlers you mentioned by doing

findEventHandlers("click", "#el")
findEventHandlers("mouseover", "#el")

This is what gets returned:

  • element
    The actual element where the event handler was registered in
  • events
    Array with information about the jquery event handlers for the event type that we are interested in (e.g. click, change, etc)
    • handler
      Actual event handler method that you can see by right clicking it and selecting Show function definition
    • selector
      The selector provided for delegated events. It will be empty for direct events.
    • targets
      List with the elements that this event handler targets. For example, for a delegated event handler that is registered in the document object and targets all buttons in a page, this property will list all buttons in the page. You can hover them and see them highlighted in chrome.

You can try it here

share|improve this answer
Thank you so much. None of the other solutions worked for me, but this worked! –  AlcubierreDrive Feb 23 at 5:44
add comment

All the examples above doesn't take care of events bounding using $('selector').live('event', handler)... You can use $(document).data('events') for these handlers.

share|improve this answer
add comment

Your Answer


