If you've added jQuery events, e.g. click():
$(element).click(function() {
debugger;
//Some code
});
You can't find that click event by browsing a DOM element's properties (in Chrome's Developer Tools or similar) when using breakpoints or using the console, e.g.:
console.log(element);
However, I discovered that you can find events of elements if you do something like this:
//Finds all events for <img> tags within the scope of
//the HTML-element with the id "container".
var elementsToFindEventsFor = $("img", $("#container"));
var events = [];
$(elementsToFindEventsFor).each(function(i, element) {
events.push($._data(element, "events"));
});
console.log(events);
jsFiddle: http://jsfiddle.net/Muskar/Mf9Eb/
This gives you the possiblity to browse the events on the returned elements when debugging, but it's not very convenient to write 5 lines of code to do debugging.
So I'm curious to see if there's any more readable and easy-to-write solutions from the jQuery API that I haven't been able to find?
Also see: How to debug JavaScript/jQuery event bindings with Firebug (or similar tool)