Event.cancelBubble
Event.cancelBubble
属性是 Event.stopPropagation()
的一个曾用名。在从事件处理程序返回之前将其值设置为true可阻止事件的传播。
语法
event.cancelBubble = bool; let bool = event.cancelBubble;
用例
-
ele.onclick = function(e) { // 在这儿可以做点儿有趣的事情 e.cancelBubble = true; }
规范
这个属性的规范并未统一. 因为他还有其他标准 W3C版: an old Working Draft of W3C DOM Level 2. 微软版: description of it on MSDN.
浏览器兼容
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Firefox (Gecko) | Chrome | Edge | Internet Explorer | Microsoft Edge | Opera | Safari |
---|---|---|---|---|---|---|---|
Basic support | 未实现 | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Firefox Mobile (Gecko) | Android | Edge | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | ? | (Yes) | ? | ? | ? |
参考
UIEvent.cancelBubble
- translated by cnvoid