1. 程式人生 > >10分鐘倒計時簡易

10分鐘倒計時簡易

var maxtime = 10*60; //
function CountDown() {
if (maxtime >= 0) {
minutes = Math.floor(maxtime / 60);
seconds = Math.floor(maxtime % 60);
if (minutes<10) minutes='0'+minutes;
if (seconds<10) seconds='0'+seconds;
// msg = "還有" + minutes + "分" + seconds + "秒";
document.all["timer"].innerHTML = minutes;
document.all["timers"].innerHTML = seconds;
// if (maxtime == 5 * 60)alert("距離結束僅剩5分鐘");
--maxtime;
} else{
clearInterval(timer);
$('.gx').hide();
$('.ygx').show();
// alert("時間到,結束!");

}
}
timer = setInterval("CountDown()", 1000);