jquery on委托事件里面加上阻止冒泡,不起作用。

原来的例子:

$(".allthree").on("click","li a",function(e){
   e.stopPropagation();//阻止冒泡
console.log(111);
})
$(document).click(function(){
console.log(222);
})

点击之后,还是会输出222;阻止冒泡不起作用

解决方法:

$(document).on("click",".allthree 
   e.stopPropagation();//阻止冒泡
console.log(111);
})
$(document).click(function(){
console.log(222);
})

相关文章: