我是要阻止从孩子到父母的事件传播,我有一堆包含一个的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/