如何绑定✀touchstart✀和✀点击✀事件,但不能两者反应

2025-03-13 22:12:56
推荐回答(1个)
回答1:

考虑一个事实,即点击将始终遵循一个触摸事件的优势,这里是我做的,无需或全局标志摆脱“鬼点击”的。$('#buttonId').on('touchstart click', function(event){
if ($(this).data("already")) {
$(this).data("already", false);
return false;
} else if (event.type == "touchstart") {
$(this).data("already", true);
}
//your code here
});

基本上,每当ontouchstart上一个标志一组并随后删除(忽略)事件触发,当点击
转载,仅供参考。