19
rated 0 times
[
23]
[
4]
/ answers: 1 / hits: 26395
/ 10 Years ago, thu, march 13, 2014, 12:00:00
I have a very basic lightweight function that counts down from 30 seconds. I have been trying to add milliseconds to it but I can't seem to get it to work correctly.
var count = 30;
var counter = setInterval(timer, 1000); //1000 will run it every 1 second
function timer() {
if (count <= 0) {
clearInterval(counter);
return;
}
count = count - 1;
document.getElementById(timer).innerHTML = count + secs; // watch for spelling
}
More From » jquery