Javascript 中的触摸与点击事件 - iOS 移动 Safari
我有一个容器 div,我设置了 touchstart
/move
/end
事件侦听器,以便在不滚动页面的情况下滚动其中的内容。现在我的问题是如何允许其中的链接可点击?我在 touchstart
处理程序中设置 e.preventDefault();
,以防止页面在滚动时出现抖动,从而阻止我的链接可点击。有什么想法或建议吗?
I have a container div I have set touchstart
/move
/end
event listeners in order to scroll the content within it without the page scrolling. Now my issue is how do you allow links within it to be clickable? I am setting e.preventDefault();
within my touchstart
handler to prevent the page from jerking while scrolling and this is preventing my links from being clickable. Any ideas or suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试绑定到
touchmove
。仅当用户触摸然后拖动时才会触发此操作,因此不应干扰他们的单击。 (在此处测试)Try binding to
touchmove
instead. This will only be triggered if the user touches and then drags, so should not interfere with them clicking. (Tested here)