http://jsfiddle.net/nunx1mhf/1/
可以试试用 iPhone 点击,真的是太灵敏了。
于是我想重新用 click 事件,但是有延时的感觉。
请大家指教一下该怎么办呢?
http://jsfiddle.net/nunx1mhf/1/
可以试试用 iPhone 点击,真的是太灵敏了。
于是我想重新用 click 事件,但是有延时的感觉。
请大家指教一下该怎么办呢?
touchend作为click的替代很不严禁。例如你滑动网页时,恰好划到绑定touchend的dom上,touchend会被触发,这显然不是用户期望的,另外如果你click和touch混用,会造成点击穿透。 github上有个fastclick的项目,你可以看下。当然也可以自己通过touchstart和touchmove 和touchend模拟tap事件,提高自己对touch的理解。
13 回答12.8k 阅读
7 回答1.9k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答873 阅读✓ 已解决
6 回答1k 阅读
2 回答1.3k 阅读✓ 已解决
"touchend" is not "click".
So, mouseup/touchend itself doesn't mean click. You have to check whether it's moved or not.
And as the touch screen is not as accurate as mouse, a move less than 10px shoud be treated as still.
But in this case the wrong handler is not the only reason causes the bug. Safari Mobile will send the same event twice, if there is a
alert
in the handler.So, record what you received, ignore redundant events. Or, do NOT use
alert
.