3
我試圖讓點擊時打開div,點擊頁面上其他任何內容時關閉,並且它在除iOS之外的所有瀏覽器上都能正常工作,只有在您點擊圖像時纔會關閉。在這裏有幾個類似的問題,主要是這個聽起來像我的問題($(document).click() not working correctly on iPhone. jquery),但對不起,我不能讓他們任何工作 - 任何人都可以幫忙嗎?iOS上的點擊事件將不起作用,除非點擊圖片...爲什麼?
and 爲什麼就是這種情況 - iOS中image/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();
});
});
見小提琴這裏: http://jsfiddle.net/atype/PqdTK/7/
嗨,你有沒有找到解決這個問題的解決方案?我也面臨同樣的問題 – User16119012
不,不幸的是,我真的很想知道爲什麼當你點擊一個圖像,但沒有點擊頁面的其餘部分。 – atype
嘗試添加遊標:指針作爲CSS樣式。 – Karlth