其他分享
首页 > 其他分享> > 阻止事件传播

阻止事件传播

作者:互联网

阻止事件传播
+ 因为事件的传播, 会导致我在一个元素上触发行为
+ 会执行多个元素的事件处理函数
+ 阻止事件传播
1. e.stopPropagation()
=> 标准浏览器使用
2. ecacelBubble = true
=> IE 低版本使用
兼容:
方式1: if (e.stopPropagation) { } else { }
方式2: try {} catch (e) {}

标签:事件处理,元素,传播,阻止,事件,stopPropagation
来源: https://www.cnblogs.com/phantomyy/p/15076907.html