手指长按事件

tachStart(item) //执行函数
function tachStart(target) {
    var time = null; 
    target.addEventListener("touchstart",function(){ //手指触摸执行
        time = setTimeout(handler,800)
    });

    target.addEventListener("touchend",function(){ //手指离开执行
        clearTimeout(time); 
    })
}
function handler(){  //长按
    console.log("你长按了我")
}

 

posted @ 2019-01-11 17:31  阿|明  阅读(348)  评论(0编辑  收藏  举报