Question

How would one print out to console, or iterate for each event listener that is attached to specific DOM element?

I have tried using .eventListenerList but I am getting undefined.

Was it helpful?

Solution

Try,

$('#elem').data('events')

update:

.data(“events”): jQuery stores its event-related data in a data object named (wait for it) events on each element. This is an internal data structure so in 1.8 this will be removed from the user data name space so it won’t conflict with items of the same name. jQuery’s event data can still be accessed via jQuery._data(element, "events") but be aware that this is an internal data structure that is undocumented and should not be modified.

So according to the data from the doc, if you use jquery version > 1.8 then you should follow this method to retrieve informations

$._data($('elem')[0],'events')

DEMO

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top