美文网首页
jquery自定义tap事件

jquery自定义tap事件

作者: xiaoaiai | 来源:发表于2017-07-29 11:47 被阅读0次
//自定义tap

$(document).on("touchstart", function(e) {
    var $target = $(e.target);
    if(!$target.hasClass("disable")) $target.data("isMoved", 0);
});

$(document).on("touchmove", function(e) {
    var $target = $(e.target);
    if(!$target.hasClass("disable")) $target.data("isMoved", 1);
});

$(document).on("touchend", function(e) {
    var $target = $(e.target);
    if(!$target.hasClass("disable") && $target.data("isMoved") == 0) $target.trigger("tap");
});

然后再jquery中直接如下写就可以了

$(el).on('tap',function(){

})

相关文章

网友评论

      本文标题:jquery自定义tap事件

      本文链接:https://www.haomeiwen.com/subject/yzgqlxtx.html