javascript - 如何确定在 javascript 或 jquery 中触发事件处理程序的顺序?

标签 javascript jquery

如果多个事件处理程序将响应一个事件,并且事件处理程序回调函数定义在不同的地方,我如何知道哪个处理程序将首先被触发,例如检查开/关时> 一个radioradio绑定(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/

相关文章:

javascript - 获取MongoDB中新创建的对象ID

php - 在 CakePHP View 中呈现 jQuery 代码时,如何使用 PHP 变量作为 <script> 标记的值?

jquery - 通过 :not in jQuery selector 隐藏除 $(this) 之外的所有内容

javascript - 使用javascript按特定元素分隔div

javascript - 获取.js文件的参数

javascript - 如何从 Ember 应用程序模板中的路由访问数据?

javascript - 使用 JS 函数来使用另一个函数的语法? Node .js

javascript - Mongoose |根据每个文档中的字段更新所有文档

jquery - 动态更新 CSS 属性

javascript - 隐藏字段并将其从检查功能中删除