How to start and stop/pause setInterval?

后端 未结 6 838
野性不改
野性不改 2020-12-05 02:59

I\'m trying to pause and then play a setInterval loop.

After I have stopped the loop, the \"start\" button in my attempt doesn\'t seem to work :

6条回答
  •  情书的邮戳
    2020-12-05 03:34

    add is a local variable not a global variable try this

    var add;
    var input = document.getElementById("input");
    
    function start() {
      add = setInterval("input.value++", 1000);
    }
    start();
    
    
    
    

提交回复
热议问题