文章出處
文章列表
時分秒 定時器
<p class="yh-hope-time"><i id="hour_show">00</i>:<i id="minute_show">00</i>:<i id="second_show">00</i></p>
<script type = "text/javascript" > var intDiff = parseInt(1800); //倒計時總秒數量 function timer(intDiff) { var f = window.setInterval(function() { var //day = 0, hour = 0 , minute = 0, second = 0; //時間默認值 if (intDiff > 0) { day = Math.floor(intDiff / (60 * 60 * 24)); hour = Math.floor(intDiff / (60 * 60)) - (day * 24); minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60); second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60); }else{ window.clearInterval(f); } if (minute <= 9) minute = '0' + minute; if (second <= 9) second = '0' + second; document.getElementById("hour_show").innerText='0'+hour; document.getElementById("minute_show").innerText=minute; document.getElementById("second_show").innerText=second; intDiff--; }, 1000); } timer(intDiff);
</script>
文章列表
全站熱搜
留言列表