I want to create a alert \"Hello\" which will show up after 10sec. I used setTimeout and it working fine. Now i would like to do counter(timer) which will show 10, 9, 8,7 ...
You can do something like that:
var count = 10; var timer = function(){ setTimeout(function(){ alert(count); if(count == 0){ //do something } else{ count--; timer(); } }, 1000); }
To run just:
timer();