stopPropagation将防止任何 父 被执行的处理程序
stopImmediatePropagation将防止任何父处理程序
,并且还 任何 其他 处理程序从执行
jQuery文档中的快速示例:
$("p").click(function(event) { event.stopImmediatePropagation();});$("p").click(function(event) { // This function won't be executed $(this).css("background-color", "#f00");});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><p>example</p>请注意,事件绑定的顺序在这里很重要!
$("p").click(function(event) { // This function will now trigger $(this).css("background-color", "#f00");});$("p").click(function(event) { event.stopImmediatePropagation();});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><p>example</p>


