我正在做一個「倒計時」,但是當它達到0時,它計爲負數; -1 -2等。我要讓我停在0jquery使倒計時
我:「天,時,分,秒」
當一切都爲00:00:00:00我希望它停止。
幫助:d
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
function makeTimer() {
var endTime = new Date("September 5, 2016 10:50:50 UTC+02:00");
var endTime = (Date.parse(endTime))/1000;
var now = new Date();
var now = (Date.parse(now)/1000);
var timeLeft = endTime - now;
var days = Math.floor(timeLeft/86400);
var hours = Math.floor((timeLeft - (days * 86400))/3600);
var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600))/60);
var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
if (hours < "10") { hours = "0" + hours; }
if (minutes < "10") { minutes = "0" + minutes; }
if (seconds < "10") { seconds = "0" + seconds; }
$("#days").html(days + "<span>Days</span>");
$("#hours").html(hours + "<span>Hours</span>");
$("#minutes").html(minutes + "<span>Minutes</span>");
$("#seconds").html(seconds + "<span>Seconds</span>");
}
setInterval(function() { makeTimer(); }, 1000);
});
</script>
檢查時'days','hours','minutes'和'seconds'是'0' ,然後停止間隔 –
檢查我發給你的那一個。它應該工作。這個例子正在工作。 – grec0o
已解決,感謝您的幫助! –