//JQ移动端页面监听单击、长按、拖动事件,直接看代码:
<
div
class
=
"box"
>按钮</
div
>
<
script
>
$(function() {
//console.log($('.box'));
$(".box").on({
touchstart: function(e) {
//长按触发事件
timeOutEvent = setTimeout(function() {
timeOutEvent = 0;
alert("你长按了");
}, 1000)
},
touchmove: function() {
clearTimeout(timeOutEvent);
timeOutEvent = 0;
alert('移动了')
},
touchend: function() {
clearTimeout(timeOutEvent);
if (timeOutEvent != 0) {
alert("你点击了");
}
return false;
}
});
});
</
script
>