有什么办法可以进行60秒倒计时...这是计时器的代码:
var count = 0;
var timer = $.timer(function() {
$('#counter').html(++count);
});
timer.set({ time : 1000, autostart : true });
我需要做什么来使这个代码像倒计时>谢谢
最佳答案
从 0 数到 60。
var count = 0, timer = setInterval(function() {
$("#counter").html((count++)+1);
if(count == 59) clearInterval(timer);
}, 1000);
或者从 60 到 0:
var count = 60, timer = setInterval(function() {
$("#counter").html(count--);
if(count == 1) clearInterval(timer);
}, 1000);
关于javascript - 从计时器开始倒计时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10541609/