使用 jQuery 和 jGestures 构建站点,并注意到一些设备(例如 iPad)不会响应“点击”事件,而是响应“点击”。
我用“tapone”替换了“click”的所有实例,在各种浏览器中进行测试后,我没有发现任何问题。浏览器包括最新版本的 IE、Firefox、Chrome for Windows 和 Ipad 4 上的 Safari。
用 on('tapone', ... 这会导致任何桌面浏览器出现问题吗?
最佳答案
click
是 native 浏览器事件。
tapone
是由 jGestures 库触发的自定义事件,用于捕获单指点击。 (它还有用于多点触控的 taptwo
等。)
如果您正在使用库,请使用它的事件。似乎在非触摸浏览器上正常化为 click
,这就是为什么您看不到任何问题。
来自documentation :
On every native touchstart, touchend, gesturestart and gestureend-event, jgestures triggers a corresponding custom event (jGestures.touchstart,jGestures.touchend,jGestures.gesturestart and jGestures.gestureend) on the event-element.
关于javascript - ('click' ) 与 ('tapone' ) 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22382948/