首页 > 技术文章 > js 移动端判断手机的点击次数和滑动执行事件

chaser-li 2017-12-07 15:32 原文

   document.addEventListener('touchstart', touch, false);
    document.addEventListener('touchmove', touch, false);
    document.addEventListener('touchend', touch, false);
    var tn = 0;
    function touch(event) {
        var event = event || window.event;
        switch (event.type) {
            case "touchstart":
                break;
            case "touchend":
                tn++;
                if (tn >= 2) { //大于点击次数
                    
                }
                break;
            case "touchmove":
           // 执行滑动事件
                break;
        }
   }        

 

推荐阅读