get all elements with onclick in them?

后端 未结 6 1325
灰色年华
灰色年华 2020-12-19 15:32

I am looking for a way to list all elements that have onclick event on a page.

6条回答
  •  抹茶落季
    2020-12-19 16:05

    If you use jQuery >= 1.4, you can get an Array of all elements with onclick attribute by writing the oneliner:

    $('body *').toArray().filter(function(el) { return $(el).attr('onclick') });
    

提交回复
热议问题