How to list events which were bind by jQuery for an element? I tried the methods from this question and none worked.
Asked
Active
Viewed 124 times
1 Answers
3
The code you linked to does work, it's just that because you used live()
(which is a deprecated function from version 1.7 on), the handler is bound to the top level element, the document
, and it uses event bubbling to figure out the original element and see if it matches your selector.
Because you tried to call the $.eventReport()
for a specific selector, rather than document
, nothing was returned.
If you change live
to on
, you will see that the alert does show something (jsFiddle). Alternatively, if you omit the selector to $.eventReport()
altogether, you will also see that a click event is bound (jsFiddle).
Example for the former:
$(function() {
$('#firstname').on("click", function(e) {
alert('clicked');
});
alert($.eventReport('#firstname'));
});

GregL
- 37,147
- 8
- 62
- 67
-
@elclanrs Yeah, you have to jump on these sorts of questions *so* quickly. Sorry you lost the race this time, my friend! – GregL Feb 21 '12 at 07:42
-
Thanks. Is there a tool or Firefox extension which does this without writing code? – Tony_Henrich Feb 21 '12 at 16:52
-
My favourite cross browser solution is the [Visual Event](http://www.sprymedia.co.uk/article/Visual+Event) bookmarklet. It's pretty awesome, give it a try. Otherwise, Firebug and some of the Firebug extensions can give you this sort of information. – GregL Feb 21 '12 at 20:58