My JS code:
var counter = 3;
var timer = setInterval(function () {counter--; if (counter == 0) {clearInterval(interval);}}, 1000);
$('#msg').hide().html('Page will refresh in ' + timer).slideDown('fast');
Why is it not working?
This is the reply I get: “Page will refresh in 14522”
All I am trying to make 3 second countdown. I don’t want any actions after that. So what is the problem?Help!
Thanks.
First, you want to show
counteron the screen, nottimer. Second, you need to update the message every time your counter changes: