javascript - 表单重置事件不会在 IE 中触发

标签 javascript jquery

此函数在 firefox/chrome 中触发:

$(document).on("reset", "form", function(){
alert("working");
});

IE 有哪些替代品(我安装了 8 个,所以我想让它从 8 个开始工作)。

最佳答案

尝试将事件处理程序直接附加到您的表单:

$(document).ready(function(){
    $("form").bind("reset", function(e) {
        alert("working");
    });
});

apparently works适用于包括 IE8 在内的多种浏览器。

由于 IE8 处理事件传播的方式,您的方法可能无法正常工作... 来自 jQuery documentation :

In Internet Explorer 8 and lower, the paste and reset events do not bubble. Such events are not supported for use with delegation, but they can be used when the event handler is directly attached to the element generating the event.

关于javascript - 表单重置事件不会在 IE 中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13436887/

相关文章:

javascript - 在每次 ajax 成功回调之前执行函数

javascript - 如何将嵌套的 JSON 数据结构展平为具有键值对的对象

javascript - Node.JS Google Calendar Promise 返回事件列表

javascript - Postman 中的 API 工作正常但在 React Native 中出现 422 错误

javascript - JQuery 不会动态追加 html 元素

javascript - ScrollTo 效果(href 到 div)

php - 如何使用 wp_enqueue_script 从 WordPress 插件导入脚本和样式

javascript - 列在运行时重新排序

javascript - 如何避免在 axios 中发送多个重复的 AJAX 请求

javascript - 在单元测试中接收语法错误