HTML:
JS:
document.getElementById('container').addEventListener('click',function () {
document.getElementById('inner').style.display = "none";
});
这时我点击子元素,也会消失。该如何避免这种情况呢?我不想也让子元素绑定click事件的方法。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
给子元素style加个
pointer-events: none;直接忽略鼠标事件。IE可能需要处理下兼容。