【问题标题】:How to run click event handler in Internet Explorer 10 using jquery?如何使用 jquery 在 Internet Explorer 10 中运行单击事件处理程序?
【发布时间】:2014-02-06 11:28:05
【问题描述】:

我正在尝试通过单击锚标记来使用 jquery 1.7 运行单击事件处理程序。 This 代码在 Firefox 中运行良好,但我无法在 IE 10 中使用相同的代码显示警告框。谁能告诉我如何在 Internet Explorer 10 中实现此功能?

$(document).ready(function() {
    $('.call-link').on('click', function (ev, evData) {
        alert("hello world");
    }); 
});

【问题讨论】:

标签: javascript jquery html internet-explorer


【解决方案1】:

它没有在 IE 中调用,因为该元素已禁用。

见:Demo

$(document).ready(function() {
    $('.call-link').click(function (ev, evData) {
        alert("hello world");
    });
});

【讨论】:

  • @Dusk 因为无输入元素上的 disabled 属性不是标准的。所以使用无效代码会产生意想不到的结果。很奇怪,您设置了 disabled 属性并仍然期望它触发附加的处理程序。与 IE 中的相反似乎更符合逻辑,不是吗?!
  • @Dusk 接受它作为答案,如果它适合你。谢谢。
【解决方案2】:

试试:

$(document).on('click', '.call-link', function (ev, evData) {
        alert("hello world");
}); 

演示http://jsbin.com/tucu/1/

【讨论】:

    【解决方案3】:

    IE 中的预期行为是按钮或链接在禁用时不会触发任何事件。您的链接已禁用。所以事件不会被触发。

    【讨论】:

      猜你喜欢
      • 2013-10-13
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2015-01-17
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多