I have written a timer. The initial minutes and hours are taken from the user. It should then count down the time. However, I don't know how to convert it to count down in a div. At the moment the action occurs in a prompt box. I don't want this.
function timer() {
var mins = 1;
var secs = 10;
while (mins >= 0) {
for(var i = secs; i > 0; i--) {
setInterval(alert(mins + ":" + i),1000);
}
secs = 59;
mins--;
}
}
Like I said in your other, similar question: don't make intervals or timeouts in loops.
while
. You don't need it.I would do this as follows;
It stops in 20 seconds for the sake of the demo purposes.
Please check this by "Run code snippet" and confirm this is what you are trying,