Reputation: 44085
How to list events which were bind by jQuery for an element? I tried the methods from this question and none worked.
Upvotes: 0
Views: 128
Reputation: 38121
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'));
});
Upvotes: 3