jQuery event.stopPropagation() 方法

event.stopPropagation() 方法阻止事件冒泡到父元素,阻止任何父事件处理程序被执行。

$("span").click(function(event){
event.stopPropagation();
alert("The span element was clicked.");
});
$("p").click(function(event){
alert("The p element was clicked.");
});
$("div").click(function(){
alert("The div element was clicked.");
});

猜你喜欢

转载自blog.csdn.net/sd19871122/article/details/86490283