Hey I'm currently practicing jquery by building a time countdown which you can click to pause or resume. But the clearInterval() is not working. Everytime I click the circle it just creat a new countdown.I don't know why.
var status="pause";
var timeleft=1500;
$("#circle").click(function(){
var timer;
if(status==="pause"){
status="start";
alert(status);
timer=setInterval(function(){
$("#timer").text(Math.floor(timeleft/60)+":"+timeleft%60);
timeleft--;
},1000);
}
else if(status==="start"){
status="pause";
alert(status);
clearInterval(timer);
}
});