问题描述
这很奇怪.我有一个委派的单击"事件,该事件在iOS上似乎不起作用.但是,如果我将事件更改为"click touchstart",它将起作用.见下文:
This is a strange one. I have a delegated 'click' event that doesn't seem to work on iOS. But if I change the event to 'click touchstart', it works. See below:
$('body').on 'click touchstart', '#cartut-proddetail', ->
$(@).fadeOut -> $(@).remove()
$('#cartut-overlay').fadeOut -> $(@).remove()
基本上,#cartut-proddetail
是模态后面的叠加层.因此,当用户点击模式时,我想删除所有叠加层.但是,如果没有touchstart
,则什么也不会发生.这是为什么?其他click
事件在iOS上也能正常工作,而且我以前从未使用过touchstart
(这实际上是第一次).为什么click
本身不起作用?
Basically, #cartut-proddetail
is an overlay behind a modal. So when the user taps off the modal, I want to remove all overlays. Without touchstart
, though, nothing happens. 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). Why doesn't click
by itself work?
推荐答案
很奇怪,它也可以在iPhone 5S& 4S.
Is very strange, it works me also, tested on iPhone 5S & 4S.
我在html正文中有一条错误/成功消息,并且如果我委托对正文或文档的单击,则关闭按钮不起作用.
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.
在找到解决方案之前,我一直尝试单击,点击和触摸任何有效的方法.我仍在努力找出其工作原因.
I tried click, tap, touch nothing worked until I found your solution. I am still working to find out why it's working.
感谢您的解决方案
这篇关于jQuery'click'事件在iOS Safari上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!