Need javascript code for button press and hold

前端 未结 6 2293
庸人自扰
庸人自扰 2020-12-03 05:13

I\'d like a short smallest possible javascript routine that when a mousedown occurs on a button it first responds just like a mouseclick and then if the user keeps the butto

6条回答
  •  长情又很酷
    2020-12-03 06:01

    something like the psuedo code below might work..

    var isClicked = false;
    var clickCounter = 100;
    function fnTrackClick(){
       if(isClicked){
          clickCounter--;
          setTimeout(clickCounter * 100, fnTrackClick);
       }
    }
    
    
    

提交回复
热议问题