tags:

views:

79

answers:

2

Is there any way to see what events are bound to an element with jQuery?

+1  A: 

If you are using Safari or Chrome, you can open up the Developer Tools and inspect the element (by clicking the magnifying glass). In the Event Listeners tab on the right it will tell you the binded events to that element, with their functions and locations.

OR to do this via code:

$('selector').data('events'); // get
console.dir($('selector').data('events')); // display in firefox firebug or webkit's developer tools
balupton
I've updated my question to include a code example to see the attached events.
balupton
The developer tools from Chrome does it display the events binded with jQuery?
Adrian Crapciu
Yep. Here is a screenshot:http://img830.imageshack.us/img830/1372/tmpu.pngI've also included in my answer how to fetch the listeners using javascript, so you don't need to use a browser console.
balupton
Nice tool. Thanks a lot
Adrian Crapciu
@Adrian - Make sure to accept this as the answer if it answered your question via the checkmark on the left :)
Nick Craver
A: 

If you don't need this in script, you can check that element in any DOM inspection tool like Firebug and see all events.

Māris Kiseļovs
with Firebug can you also see what events are bound with jQuery?
Adrian Crapciu
Yes, and with anything other. Also you can do the same with Chrome/Safari/Opera Developer Tools.
Māris Kiseļovs
I must be blind but I can't find the Event Listener tab in Firebug. I use Firebug 1.5.4 and Firequery.
Adrian Crapciu
Then you can check this discussion - http://stackoverflow.com/questions/570960/how-to-debug-javascript-jquery-event-bindings-with-firebug-or-similar-tool
Māris Kiseļovs
it seems that the Events Panel is added from Firefox 3.7a1pre not in Firefox 3.6.*
Adrian Crapciu