tags:

views:

311

answers:

2

I need to select all elements, that has binded "click" event? Is there such selector exists?

A: 

No. You can iterate over all elements and check if they have an event binding. But that wouldn't be very efficient unless you have a clue what kind of elements would have that event binding so you can narrow the search.

Vasil
it might not be so horribly ineffecient, because I suspect jquery does a lot of looping over everything for any query
cobbal
+6  A: 

It is not supported natively by jQuery, but you can write your own custom selector using hasEvent plugin :

jQuery.expr[":"].click = "jQuery(a).hasEvent('click');";

$("a:click").doStuff();

EDIT :

There is also the Event Bound Selector plugin which is more complete and works out of the box, but is also bigger.

ybo
Great. I wonder how it works.
Vasil