有人知道为什么touchend事件会在touchstart事件期间触发吗?这只会在第二次发生。
快速代码片段:
function touchstart (event) {
$(event.target).one('touchend', function () {
alert('fired');
}
}
所以在第一次启动时,它工作得很好。第二次,它会在touchstart上触发警报。
编辑:
看起来这可能只是一个iPhone问题
发布于 2012-12-31 05:49:01
在touchend事件中触发out...by会导致各种问题。当你点击“确定”时,它会触发touchstart,所以下次你触摸元素时,touchend也会被触发。幸运的是,我使用了警告来检查我的代码--所以一旦删除了它,我的代码就可以完美地工作了!
发布于 2013-10-22 20:47:36
只需将"touchend“处理程序的代码放在0ms的setTimeout中。如下所示:
$(someElement).on("touchend",
function(){
setTimeout(function(){
/*Your code*/
}, 0);
});
https://stackoverflow.com/questions/14091982
复制相似问题