gpt4 book ai didi

javascript - 将 div 覆盖在传单上并停止鼠标操作传播

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:39:04 25 4
gpt4 key购买 nike

如何停止在 div 上单击和滚动并覆盖传单 map 的传播?这似乎很棘手......有点像

customPreventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}

document.getElementById('no-scrolling-clicking').onmousewheel =
function (e) {
document.getElementById('prevent-scrolling').scrollTop -= e.wheelDeltaY;
customPreventDefault(e);
}
}

什么都不做。它也需要在 IE 中工作...

http://jsfiddle.net/LnzN2/4888/

最佳答案

parent-div 移到 map div 之外。

将您的 HTML 更改为:

<div 
id="map">

</div>
<div
id='parent-div'
class='some-div'>
I am the parent! Like the leaflet map, I don't want the mouse events clicking/scrolling bubbling onto me neither.
<div
class='some-div'
id='no-scrolling-clicking'>
Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me!
</div>
</div>

关于javascript - 将 div 覆盖在传单上并停止鼠标操作传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52309356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com