$.fn.longPress = function(fn) {
var timeout = undefined;
var $this = this;
for(var i = 0;i<$this.length;i++){
$this[i].addEventListener('touchstart', function(event) {
timeout = setTimeout(fn, 800); //长按时间超过800ms,则执行传入的方法
}, false);
$this[i].addEventListener('touchend', function(event) {
clearTimeout(timeout); //长按时间少于800ms,不会执行传入的方法
}, false);
}
}
$('.sk-card').longPress(function(){
///-----------------
});
版权声明:本文为songyanfei1205原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。