简体   繁体   English

jQuery'click'事件在iOS Safari上不起作用?

[英]jQuery 'click' event doesn't work on iOS Safari?

This is a strange one. 这是一个奇怪的。 I have a delegated 'click' event that doesn't seem to work on iOS. 我有一个委派的“点击”事件,该事件在iOS上似乎不起作用。 But if I change the event to 'click touchstart', it works. 但是,如果我将事件更改为“ click touchstart”,它将起作用。 See below: 见下文:

$('body').on 'click touchstart', '#cartut-proddetail', ->
  $(@).fadeOut -> $(@).remove()
  $('#cartut-overlay').fadeOut -> $(@).remove()

Basically, #cartut-proddetail is an overlay behind a modal. 基本上, #cartut-proddetail是模态后面的叠加层。 So when the user taps off the modal, I want to remove all overlays. 因此,当用户点击模式时,我想删除所有叠加层。 Without touchstart , though, nothing happens. 但是,如果没有touchstart ,则什么也不会发生。 Why is that? 这是为什么? Other click events work just fine on iOS, and I never had to use touchstart before (this is literally the first time). 其他click事件在iOS上也能正常工作,而且我以前从未使用过touchstart (这实际上是第一次)。 Why doesn't click by itself work? 为什么click本身不起作用?

Is very strange, it works me also, tested on iPhone 5S & 4S. 很奇怪,它也可以在iPhone 5S和4S上测试。

I have an error/success message that is prepended in the html body, and the close button doesn't work if I delegate the click on the body or the document. 我在html正文中有一条错误/成功消息,并且如果我委托单击正文或文档,则关闭按钮不起作用。

I tried click, tap, touch nothing worked until I found your solution. 我尝试单击,点击和触摸,在找到您的解决方案之前没有任何效果。 I am still working to find out why it's working. 我仍在努力找出它为什么起作用。

Thanks for the solution 感谢您的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM