Jquery Selector that search for events

前端 未结 3 1567
暗喜
暗喜 2021-01-07 11:58

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

3条回答
  •  情书的邮戳
    2021-01-07 12:32

    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.

提交回复
热议问题