gpt4 book ai didi

javascript - IE10 : pointer-events: none still trigger the element

转载 作者:行者123 更新时间:2023-11-28 16:08:43 25 4
gpt4 key购买 nike

我在 IE <=10 中使用我的应用程序时遇到问题。

我正在使用这个 polyfill在 IE 中支持 pointer-events: none

但我仍然可以点击我的元素,在其他浏览器中我不能。

我做错了什么?

HTML:

<!DOCTYPE html>
<html>

<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>

<body>
<h1>Hello Plunker!</h1>

<div class="pointed" data-pointer-events-none>ClickME!</div>
</body>

</html>

JS:

 $(window).load(function(){
$('.pointed').click(function(){
alert('clicked');
});
PointerEventsPolyfill.initialize({});
});

plunker :

为什么我还没有禁用指针?

最佳答案

您可以使用简单的 jQuery 来支持 IE,而不是使用 polifyll,

请看下面的片段:

$(document).on('mousedown', '.pointed', function(e) {
$(this).hide();
var PointerElement = document.elementFromPoint(e.clientX, e.clientY);
$(this).show();
$(PointerElement).mousedown(); //Manually fire the event for desired underlying element
return false;
});
.pointed {
pointer-events: none
/*for every non-IE browser*/
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div class="pointed">ClickME!</div>

关于javascript - IE10 : pointer-events: none still trigger the element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33566848/

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