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

html, javascript, jquery

Solution

This should get you a list of events:

jQuery(theElement).data('events');

Problem

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??

Original source

Related problems