Javascript 单击“在iPhone/iPad中不工作”时关闭灯箱

Javascript 单击“在iPhone/iPad中不工作”时关闭灯箱,javascript,jquery,iphone,ipad,Javascript,Jquery,Iphone,Ipad,下面是我正在使用的代码。在Windows和安卓系统中,点击外部会关闭灯箱,但在iPhone和iPad中不会 JS: $(document).on('click', function(event) { if ($(event.target).has('.pop-up').length) { $('.pop-up-overlay').hide(); } }); <div class="pop-up-overlay"> <div class="pop-up"&g

下面是我正在使用的代码。在Windows和安卓系统中,点击外部会关闭灯箱,但在iPhone和iPad中不会

JS:

$(document).on('click', function(event) {
  if ($(event.target).has('.pop-up').length) {
    $('.pop-up-overlay').hide();
  }
});
<div class="pop-up-overlay">
  <div class="pop-up">
    <p>Popup contents goes here.</p>
  </div>
</div>
HTML:

$(document).on('click', function(event) {
  if ($(event.target).has('.pop-up').length) {
    $('.pop-up-overlay').hide();
  }
});
<div class="pop-up-overlay">
  <div class="pop-up">
    <p>Popup contents goes here.</p>
  </div>
</div>

弹出内容在这里


也许可以在ios上尝试:

$(文档)。在(“单击touchstart”)上,函数(事件){
if($(event.target).has('.pop-up').length){
$('.pop-up overlay').hide();
}
});

弹出内容在这里


要查看结果,您应该在一次编辑中添加两个代码段,您分别添加了两种语言。我是新来的,这是我的第一篇文章。上述代码不适用于Safari(Mac)和Chrome(Mac)。请你再帮我一次好吗?