Last active
September 18, 2015 18:19
-
-
Save amurrell/0e10f4e4ad99e600830d to your computer and use it in GitHub Desktop.
Used to debug jQuery events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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