H5页面监听长按事件
var timeOutEvent;
$(document).on("touchstart","body img",function(e){
var that = this;
timeOutEvent = setTimeout("longPress()",500);//500设置时间
picUrl = $(that).attr('src');
e.preventDefault();
})
$(document).on("touchmove","body img",function(e){
clearTimeout(timeOutEvent);
timeOutEvent = 0;
})
$(document).on("touchend","body img",function(e){
clearTimeout(timeOutEvent);
if(timeOutEvent!=0){
//alert("你这是点击,不是长按");
}
return false;
})
function longPress(){
timeOutEvent = 0;
//alert("长按事件触发发");
}
H5页面监听长按事件
最新推荐文章于 2024-05-11 01:13:56 发布