长按原生js写法
<script> var num = 0 ; function whichElement(e){ var timer_alert = setTimeout(function() { if(e.which==1) { num++ if(num==2){ num=0; alert( "鼠标长按" ); }else{ whichElement( e ); } } }, 1000) ; } </script>
时间: 2024-10-17 23:56:36
长按原生js写法
<script> var num = 0 ; function whichElement(e){ var timer_alert = setTimeout(function() { if(e.which==1) { num++ if(num==2){ num=0; alert( "鼠标长按" ); }else{ whichElement( e ); } } }, 1000) ; } </script>