您的位置:首页 > 移动开发 > 微信开发

微信公众号网页长按屏蔽默认点击事件后再添加其他事件

2017-11-28 10:11 411 查看
window.ontouchstart = function(e) {
e.preventDefault();
};
$.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);
}
}
$('#div').longPress(function(){
alert(1);
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐