标签:
代码编写:
$.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); }, false); $this[i].addEventListener(‘touchend‘, function(event) { clearTimeout(timeout); }, false); } }
代码使用:
$(select).longPress(function(){ alert(1); });
标签:
原文地址:http://www.cnblogs.com/Silababy/p/4275240.html