码迷,mamicode.com
首页 > 其他好文 > 详细

长按按钮事件函数

时间:2016-12-02 21:51:56      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:部分   his   end   bsp   按钮   pad   function   timeout   是你   

这里是代码的逻辑编写部分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$.fn.longPress = function(fn) {
        var timeout = undefined;
        var $this this;
        alert(this.length);
        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是你所要获取的元素

1
2
3
$(select).longPress(function(index){
      alert("你已长按");
  });

长按按钮事件函数

标签:部分   his   end   bsp   按钮   pad   function   timeout   是你   

原文地址:http://www.cnblogs.com/zhishiqu/p/6127094.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!