I want a simple JavaScript countdown which counts to 5 and then stops. I want to show the current value (1,2,3,4,5)
I tried:
function countdown() {
jAlert('test', i);
i++;
if (i >= 5) {
clearInterval(aktiv);
}
};
var aktiv = setInterval('countdown()', 1000);
var i = 0;
But every time I insert that i in to jAlert it wont work any more. What is wrong there?
1 Answer