Event.cancelBubble

Event.cancelBubble 属性是 Event.stopPropagation()的一个曾用名。在从事件处理程序返回之前将其值设置为 true 可阻止事件的传播。

语法

event.cancelBubble = bool;
let bool = event.cancelBubble;

用例

js
ele.onclick = function (e) {
  // 在这儿可以做点儿有趣的事情
  e.cancelBubble = true;
};

规范

这个属性的规范并未统一。 因为他还有其他标准 W3C 版: an old Working Draft of W3C DOM Level 2. 微软版: description of it on MSDN.

浏览器兼容性

BCD tables only load in the browser

参考