jQuery event triggering on all listeners

前端 未结 1 1477
悲&欢浪女
悲&欢浪女 2020-12-31 09:46

I have a custom event I\'ve made which I would like to trigger at some point with no relevance to selection.

I.E - I would like to do something that would behave as

相关标签:
1条回答
  • 2020-12-31 10:40

    You can trigger an event on everything that has a handler bound like this:

    $.event.trigger('customEvent'); 
    

    This loops through $.cache to find what actually has a handler, then fires on those elements...rather than just finding every element and firing the event on each one.

    0 讨论(0)
提交回复
热议问题