简单的jquery计数器
大家好,我有一个非常简单的 jquery 计数器,
var count = 10;
countdown = setInterval(function(){
$("p.countdown").html(count + " seconds remaining!");
if (count == 0) {
alert('done');
}
count--;
}, 1000);
我怎样才能让它在达到 0 后重置而不是进入负数???所以它不断迭代。
http://jsfiddle.net/isimpledesign/mSQdp/
任何帮助
Hi all i have got this really simple jquery counter
var count = 10;
countdown = setInterval(function(){
$("p.countdown").html(count + " seconds remaining!");
if (count == 0) {
alert('done');
}
count--;
}, 1000);
How can i make it reset after it gets to 0 instead of going into minus???? so it keep iterating.
http://jsfiddle.net/isimpledesign/mSQdp/
any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
要重置并重复,请将
count = 11;
放在alert('done');
之后。要停止,请将
clearInterval(countdown);
放在alert('done');
之后。To reset and repeat, put
count = 11;
after thealert('done');
.To stop, put
clearInterval(countdown);
after thealert('done');
.试试这个
Try this
就像这样:
您可能还想查看 jQuery 倒计时插件
Just like this:
You might also want to look at the jQuery countdown plugin