阻止事件冒泡

第一种:

给元素添加click事件

$("span").click(function(event){

  event.stopPropagation(); alert("The span element was clicked.");

});

第二种:

οnclick=xxx()来调用点击事件时

event.stopPropagation();

会报错:Typeerror:Cannot read property ‘stopPropagation’ of undefined

// 正确写法:

//阻止向上冒泡

window.event.stopPropagation();

原文地址:https://www.cnblogs.com/wpTing/p/12381891.html