长按识别二维码所联想到的长按问题

 

长按原生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>

 

posted @ 2016-05-03 13:28  zcynine  阅读(230)  评论(0编辑  收藏  举报