How to debug JavaScript/jQuery event bindings with Firebug (or similar tool)
Solution 1:
See How to find event listeners on a DOM node .
In a nutshell, assuming at some point an event handler is attached to our element (eg): $('#foo').click(function() { console.log('clicked!') });
We inspect it like so:
jQuery 1.3.x
jQuery 1.4.x
See jQuery.fn.data (where jQuery stores our handler internally).
See jQuery.fn.data (where jQuery stores our handler internally).
jQuery 1.8.x
Solution 2:
There's a nice bookmarklet called Visual Event that can show we all the events attached to an element. It has color-coded highlights for different types of events (mouse, keyboard, etc.). When we hover over them, it shows the body of the event handler, how it was attached, and the file/line number (on WebKit and Opera). We can also trigger the event manually.
It can't find every event because there's no standard way to look up what event handlers are attached to an element, but it works with popular libraries like jQuery, Prototype, MooTools, YUI, etc.
Solution 3:
The Eventbug extension has been released yesterday, see here
Solution 4:
Here's a plugin which can list all event handlers for any given element/event:
Use it like this:
Solution 5:
Use $._data(htmlElement, "events") in jquery 1.7+;