如何在countdown = 0时停止我的javascript函数?如何阻止我的JavaScript倒计时?
JS:
var settimmer = 0;
$(function(){
window.setInterval(function() {
var timeCounter = $("b[id=show-time]").html();
var updateTime = eval(timeCounter)- eval(1);
$("b[id=show-time]").html(updateTime);
}, 1000);
});
HTML:
<b id="show-time">20</b>
除非出于某种疯狂的原因''setInterval''和'clearInterval'在您的代码中被遮挡,否则显式引用窗口是不必要的。 – 2012-03-30 18:56:40