防止点击事件影响父jquery

我是要阻止从孩子到父母的事件传播,我有一堆包含一个的li标签.

$('li a[rel=close]').live('click',function(e){
    e.stopPropagation();
    e.preventDefault();
})

但它并没有停止事件.任何建议?

解决方法

stopPropagation有关于live的问题,来自jQuery stopPropagation docs –

Since the .live() method handles events once they have propagated to
the top of the document,it is not possible to stop propagation of
live events

正如Rob W所说,你的代码可以正常使用bind,这是一个演示 – http://jsfiddle.net/TmKyT/

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...