頁面倒計時
html:
<div class="timer">
<strong id="minute">0分</strong>
<strong id="second">0秒</strong>
</div>
Jquery:
//計時器
var intDiff = parseInt(1800);//倒計時總秒數(shù)量
function timer(intDiff) {
window.setInterval(function () {
var minute = 0,
second = 0;//時間默認(rèn)值
if (intDiff > 0) {
minute = Math.floor(intDiff / 60);
second = Math.floor(intDiff) - (minute * 60); }
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('#minute').html('<s></s>' + minute + '分');
$('#second').html('<s></s>' + second + '秒');
int Diff--;
if (intDiff <= 0) { clearInterval(timer); //定時器清除;
history.back(-1);
}
}, 1000); }
$(function () {
timer(intDiff);
});