Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
85
rated 0 times [  86] [ 1]  / answers: 1 / hits: 15223  / 12 Years ago, thu, may 10, 2012, 12:00:00

Is there any way to make a countdown with 60 seconds... Here is the code for timer:



var count = 0;
var timer = $.timer(function() {
$('#counter').html(++count);
});
timer.set({ time : 1000, autostart : true });


What I need to chabge to make this code like countdown> THANKS


More From » jquery

 Answers
14

Counts from 0 to 60.



var count = 0, timer = setInterval(function() {
$(#counter).html((count++)+1);
if(count == 59) clearInterval(timer);
}, 1000);


Or from 60 to 0:



var count = 60, timer = setInterval(function() {
$(#counter).html(count--);
if(count == 1) clearInterval(timer);
}, 1000);

[#85660] Wednesday, May 9, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rey

Total Points: 415
Total Questions: 100
Total Answers: 100

Location: Croatia
Member since Fri, Sep 11, 2020
4 Years ago
;