Skip to content

Instantly share code, notes, and snippets.

@amurrell
Last active September 18, 2015 18:19
Show Gist options
  • Save amurrell/0e10f4e4ad99e600830d to your computer and use it in GitHub Desktop.
Save amurrell/0e10f4e4ad99e600830d to your computer and use it in GitHub Desktop.
Used to debug jQuery events
// Use to debug - Find out events on a jQuery object. Might not work for 1.8+ jQuery.
// Run this in your console, for example, just alter the get_events call.
function get_events(selector) {
var element = $(selector);
if (element.length > 1)
return 'too many matched elements. make it unique';
if (element.length < 1)
return 'no matched elements';
if (element.data("events") === undefined) {
return 'no events on this selector';
}
$.each(element.data("events"), function(i, event) {
alert(i);
$.each(event, function(j, h) {
alert(h.handler);
});
});
}
// Now use it, using a selector
get_events('body');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment