[英]How to respond to 'click' instead of 'swipe' on mobile in jquery?
I have this code, on a mobile page: 我在移动页面上有以下代码:
jQuery(document).ready(function($){
$('a').on('click touchend', function(e) {
/* Do something */
});
});
works fine, but on mobile devices it's called both for click on links and on swipe (that is touching the link, scrolling and lifting the finger). 效果很好,但是在移动设备上,单击链接和滑动(即触摸链接,滚动并抬起手指)都可以称为“链接”。 How can I modify this to be called only on click?
如何将其修改为仅在点击时调用?
I tried 'tap', 'click' and doesn't seem to work, nor I can find a good list of all the possibile events fired on mobile... 我尝试了“轻按”,“单击”,但似乎没有用,也找不到在移动设备上触发的所有可能发生的事件的好清单...
jQuery(document).ready(function($){
$('a').on('vclick', function(e) {
/* Do something */
});
});
On mobile devices, it seems that the first click on a menu is taken as an hover instead of a click, so the solution in my case was 在移动设备上,菜单上的第一次单击似乎是悬停而不是单击,因此我的解决方案是
jQuery(document).ready(function($){
$('a').hover(function(e) {
/* Do something */
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.