JavaScript 阻止事件冒泡 | 解决代码冲突
// 假设'a'元素和'b'元素有冒泡
document.getElementById('a').onclick = function(e){
e.stopPropagation(); //阻止冒泡
// 其他代码
}
document.getElementById('b').onclick = function(e){
e.stopPropagation(); //阻止冒泡
// 其他代码
}
原文地址: http://www.cveoy.top/t/topic/lhzA 著作权归作者所有。请勿转载和采集!