至尊技术网 - 长按
2022-05-21T15:44:00+08:00
Typecho
https://www.zzwws.cn/feed/atom/tag/%E9%95%BF%E6%8C%89/
https://www.zzwws.cn/archives/6341/
2022-05-21T15:44:00+08:00
2022-05-21T15:44:00+08:00
悠悠楠杉
http://www.zzwws.cn
$(".text").on({
touchstart: function(e) {
var oSpan = e.currentTarget.lastElementChild
// 长按事件触发
timeOutEvent = setTimeout(function() {
timeOutEvent = 0;
console.log('你长按了');
}, 500);
},
touchmove: function() {
clearTimeout(timeOutEvent);
timeOutEvent = 0;
},
touchend: function() {
clearTimeout(timeOutEvent);
if (timeOutEvent != 0) {
console.log('你点击了');
}
return false;
}
})
]]>