Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way in javascript to detect if an element has any events attached to it?

I have a list of links on the page and sometimes they have events attached to them and sometimes not (they just don't do anything). I want to say, 'if this element has no event handlers (basically it doesn't do anything), then add a class of disabled to it. I googled it but didn't find anything for detecting event handlers. Does anyone know of a way to do something like this??

like image 265
FairyQueen Avatar asked Dec 10 '22 00:12

FairyQueen


1 Answers

This should get you a list of events:

jQuery(theElement).data('events');
like image 180
Manuel Avatar answered May 01 '23 20:05

Manuel