gpt4 book ai didi

jquery - iOS 上的点击事件将不起作用,除非点击图像时......为什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:41:50 24 4
gpt4 key购买 nike

我试图让 Div 在单击时打开,在单击页面上的任何其他内容时关闭,它在除 iOS 以外的所有浏览器上都能正常工作,只有在单击图像时它才会关闭。这里有几个类似的问题,主要是这个听起来像我的问题 ( $(document).click() not working correctly on iPhone. jquery ) 但抱歉,我无法让他们中的任何一个工作 - 谁能帮忙?

为什么是这种情况 - iOS 中的图像/jQuery 有什么特别之处?

HTML:

<p>Click on the box to show the div</p>
<div id="toolbar">
<div id="searchbox">
<p>Click anywhere else to hide the div</p>
</div>
</div>
<img src="http://upload.wikimedia.org/wikipedia/commons/c/ce/Example_image.png" width="240" height="240" />

jQuery:

$(document).ready(function () {
$('#toolbar').click(function (e) {
$('#searchbox').fadeIn();
e.stopImmediatePropagation();
});
$(document).click(function (e) {
$('#searchbox').fadeOut();
});

});

请看这里的 fiddle : http://jsfiddle.net/atype/PqdTK/7/

最佳答案

我的印象是,对于严格意义上不是 href 的元素,第一次按下是“悬停”事件,第二次按下手指是“点击”。

关于jquery - iOS 上的点击事件将不起作用,除非点击图像时......为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18096305/

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