function _tap(dom,callBack){ var startTime=0; var delayTime=200; var isMove=false; dom.addEventListener("touchstart",function(e){ startTime=Date.now(); }); dom.addEventListener("touchmove",function(e){ if(isMove==false){ isMove=true; } }); dom.addEventListener("touchend",function(e){ if(isMove){ isMove=false; return; } if(Date.now()-startTime>delayTime) return; callBack(e); }); } function x(){ console.log(1); }
_tap(document.getElementById('my_dom'),x);