javascript - jQuery:拦截原始 DOM 就绪事件?

标签 javascript jquery

是否可以以某种方式拦截 DOM 就绪事件,以便通常在 $(document).ready(function() { ... } 内触发的任何内容都不会被执行?然后手动触发事件以便代码执行?

就我而言,我有大量现有代码已经依赖于 $(document).ready(function() { ... } 并且我希望我不会进行搜索/替换以使其全部依赖于自定义手动触发事件。

最佳答案

jQuery.trigger()就是为了这样的需要而生的

Any event handlers attached with .bind() or one of its shortcut methods are triggered when the corresponding event occurs. They can be fired manually, however, with the .trigger() method. A call to .trigger() executes the handlers in the same order they would be if the event were triggered naturally by the user:

关于javascript - jQuery:拦截原始 DOM 就绪事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5658774/

相关文章:

javascript - 鼠标悬停或悬停 vue.js

javascript - 使用 Apps 脚本在 Google 表格中用新数据替换重复行

javascript - 当通过 if 条件时退出 foreach

jquery - jquery 中的 if/else

javascript - 删除记录确认消息

javascript - 跨域请求子域

jquery - 在文档单击时取消固定 div

javascript - 将 Kendo UI 网格高度设置为包装器的 100%

javascript - 为什么我的自动完成功能不起作用?

javascript - 通过 javascript 通过传递 URL 来读取/处理图像 - 类似于 PHP 中的 file_get_contents?