在 iPhone/iPad 中单击外部时关闭灯箱不起作用
Close lightbox on clicking outside not working in iPhone/iPad
下面是我正在使用的代码。单击外部可关闭 Windows 和 Android 中的灯箱,但不会关闭 iPhone 和 iPad 中的灯箱。
JS:
$(document).on('click', function(event) {
if ($(event.target).has('.pop-up').length) {
$('.pop-up-overlay').hide();
}
});
HTML:
<div class="pop-up-overlay">
<div class="pop-up">
<p>Popup contents goes here.</p>
</div>
</div>
也许 ios 试试这个:
$(document).on("click touchstart", function(event) {
if ($(event.target).has('.pop-up').length) {
$('.pop-up-overlay').hide();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pop-up-overlay">
<div class="pop-up">
<p>Popup contents goes here.</p>
</div>
</div>
此 link
中提出了类似的问题
下面是我正在使用的代码。单击外部可关闭 Windows 和 Android 中的灯箱,但不会关闭 iPhone 和 iPad 中的灯箱。
JS:
$(document).on('click', function(event) {
if ($(event.target).has('.pop-up').length) {
$('.pop-up-overlay').hide();
}
});
HTML:
<div class="pop-up-overlay">
<div class="pop-up">
<p>Popup contents goes here.</p>
</div>
</div>
也许 ios 试试这个:
$(document).on("click touchstart", function(event) {
if ($(event.target).has('.pop-up').length) {
$('.pop-up-overlay').hide();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pop-up-overlay">
<div class="pop-up">
<p>Popup contents goes here.</p>
</div>
</div>
此 link
中提出了类似的问题