如果多个事件处理程序将响应一个事件,并且事件处理程序回调函数定义在不同的地方,我如何知道哪个处理程序将首先被触发,例如检查开/关
时> 一个radio
,radio
绑定(bind)了多个handler,那么如何判断先执行哪个呢?
最佳答案
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.
关于javascript - 如何确定在 javascript 或 jquery 中触发事件处理程序的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7992634/