I have some code that works fine in FF but not in IE. I have read other posts saying that the Jquery live method does not support change events but I am using a click event. Here is my code, it is inside $(document).ready(function():

我有一些代码在FF中工作正常,但在IE中没有。我读过其他帖子说Jquery live方法不支持更改事件,但我使用的是click事件。这是我的代码,它在$(document).ready(function()里面:

$("a").live("click", function(e) { 
        alert("link clicked");
        //do stuff
    });

If FF the alert is fired but not in IE. When I use $("a").click it works fine, the problem is that I need to the function to be applied to links that do not exist when the page is first loaded (they will be created via ajax calls at a later stage).

如果FF警报被触发但不在IE中。当我使用$(“a”)。单击它工作正常,问题是我需要将函数应用于首次加载页面时不存在的链接(它们将在稍后通过ajax调用创建阶段)。

Do I have any options here. We are using jquery-1.4.1.min.js.

我有这里的选择吗?我们正在使用jquery-1.4.1.min.js。

Thanks in advance

提前致谢

2 个解决方案

#1


2

if those links are within a specific content, you can use:

如果这些链接在特定内容中,您可以使用:

$('#link_container_id').delegate('a', 'click', function(e){
   alert('link clicked');
});

.delegate() will watch if there are any events (click in your case) bubbling up, if so it checks for the target and compares it to 'a' in your case. Should work, but untested.

.delegate()将观察是否有任何事件(点击您的情况)冒泡,如果是,它会检查目标并将其与您的情况中的“a”进行比较。应该工作,但未经测试。

更多相关文章

  1. bootstrap,模态对话框,shown.bs.modal事件不会触发
  2. 更改html隐藏字段的事件
  3. JQuery 总结(3) jQuery 各种事件
  4. jQuery 选择器 与 事件
  5. jquery不会对select/选项更改事件作出反应。
  6. 使用HTML5验证时如何绑定到提交事件?
  7. jquery自定义事件
  8. jQuery学习笔记- focus和blur事件妙用
  9. 具有嵌套元素的jQuery悬停事件

随机推荐

  1. SQLSERVER 中表变量与临时表
  2. 急!如何得到sql数据库更新的日志?
  3. SHOW STATUS 查看各种类型SQL执行的频率
  4. 这个查询能用变量写出来吗?
  5. mysql创建任务事件
  6. 通向SQLServer安全级别3的楼梯:主体和安全
  7. mysql 千万级的 count统计对比
  8. 【安全牛学习笔记】MsSQL高级注入
  9. 数据库对象的创建和管理
  10. centos65安装简测mysql cluster 7.3.7