简体   繁体   中英

how to determine the order of being triggered of a event handler in javascript or jquery?

如果多个事件处理程序将响应一个事件,事件处理的回调函数在不同的地方被定义,我怎么能知道哪些处理程序将首先触发,egwhen检查on/off一个radioradio结合多个处理程序,所以如何判断哪一个先被执行?

Javascript event handler order

If you use JQuery to bind your events, it guarantees that handlers are fired in the same order that they were bound. Otherwise the order is officially undefined.

If you cannot use JQuery or a similar framework you can easily simulate this by using your own custom even binding, where your generic handler is a function which keeps an array of functions and calls them in order.

Documentation -
All handlers bound to that event type for the element are fired. If there are multiple handlers registered, they will always execute in the order in which they were bound. After all handlers have executed, the event continues along the normal event propagation path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM