Is it possible to determine whether an element has a click handler, or a change handler, or any kind of event handler bound to it using jQuery?
Furthermore, is it possible to determine how many click handlers (or whatever kind of event handlers) it has for a given type of event, and what functions are in the event handlers?
You can get this information from the data cache.
For example, log them to the console (firebug, ie8):
console.dir( $('#someElementId').data('events') );
or iterate them:
jQuery.each($('#someElementId').data('events'), function(i, event){ jQuery.each(event, function(i, handler){ console.log( handler.toString() ); }); });
Another way is you can use the following bookmarklet but obviously this does not help at runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With