TuWenHao
//长按事件触发
$.fn.longPress = function(fn) {

    var timeout = undefined;
    var $this = this;
    for(var i = 0; i < $this.length; i++) {
      (function(target) {
        var timeout;
        target.addEventListener(\'touchstart\', function(event) {
          timeout = setTimeout(function() {
            //fn.apply(target);
            fn(event);
          }, 500);
        }, false);
        target.addEventListener(\'touchend\', function(event) {
          clearTimeout(timeout);
        }, false);
      })($this[i]);
    }
}
//调用事件 $(
"#id").longPress(function(e){ alert("adfs"); });

 

分类:

技术点:

相关文章:

  • 2021-05-16
  • 2021-11-30
  • 2021-06-22
  • 2021-12-28
  • 2021-12-11
  • 2021-11-17
  • 2021-08-08
  • 2021-08-16
猜你喜欢
  • 2021-11-20
  • 2021-11-02
  • 2021-09-30
  • 2021-07-23
  • 2021-12-23
  • 2021-11-27
相关资源
相似解决方案