How to stop a stopwatch when it reaches 0 in jquery

I am new to jquery so I might be making some. obvious mistake here, but the if statement at the bottom is not running. I am making a timer, and I want the stopwatch to stop when it reaches 0, although I don't know how to do that either.

var i = 60;
 
$('button[id=skill]').click(function (e){
$(this).hide(1000)
    setInterval(function () {
        $("#stopWatch").html(i);
        i--;
    }, 1000);
});

$("#resetButton").click(function (e) {
    i = 60;return false;
 
});
if(i==0)
{
  i=20
 //I also want the stopwatch to stop when it reaches 0, don't know how to do that though.
}


from Recent Questions - Stack Overflow https://ift.tt/3GQ8u5C
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)