As the question said, i need the list of events bound to a specific element.
I mean events like click, mouseover etc bound to that element at the loading of the dom.
(Stupid) example:
$("#element").click(function()
{
//stuff
});
$("#element").mouseover(function()
{
//stuff
});
$("#element").focus(function()
{
//stuff
});
Result:
click, mouseover, focus
Right-click on the search icon button and choose “inspect” to open the Chrome developer tools. Once the dev tools are open, switch to the “Event Listeners” tab and you will see all the event listeners bound to the element. You can expand any event listener by clicking the right-pointing arrowhead.
bind() method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to . bind() occurs.
The jQuery bind() event is used to attach one or more event handlers for selected elements from a set of elements. It specifies a function to run when the event occurs. It is generally used together with other events of jQuery. Syntax: $(selector).
Every event is added to an array.
This array can be accessed using the jQuery data method:
$("#element").data('events')
To log all events of one object to fireBug just type:
console.log ( $("#element").data('events') )
And you will get a list of all bound events.
Update:
For jQuery 1.8 and higher you have to look into the internal jQuery data object:
$("#element").each(function(){console.log($._data(this).events);});
// or
console.log($._data($("#element")[0]).events);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With