2012-07-16 191 views
-9

我需要設置倒數計時器。剩餘時間格式爲"00:00:00"在JavaScript中設置倒數計時器

我需要創建一個倒數計時器,在四個<span></span>元素內顯示分鐘和秒鐘。

5-with in one span element 
6-with in second span element 
4-with in third span element 
5-with in last span element 

<span>5</span><span>6</span><span>4</span><span>5</span> 
+2

你試過了什麼? – 2012-07-16 05:45:17

+0

你是Google嗎? http://stackoverflow.com/questions/1191865/code-for-a-simple-javascript-countdown-timer?rq=1 http://stackoverflow.com/questions/460474/how-to-set-a-timer -in-javascript?rq = 1 http://stackoverflow.com/questions/2221801/javascript-jquery-time-count-down?rq=1 http://stackoverflow.com/questions/2610580/create-a-count -up定時器功能於JavaScript的jquery的?RQ = 1 – 2012-07-16 05:47:47

回答

1

這將讓你開始,推動你在正確的:

例如,當我有56分45秒,其值應設置如下方向。其餘的由你決定。

var start = 5; 

function countdown() { 
    $("#spanId").html(start--); 
    if (start) 
     setTimeout(countdown, 1000); 
} 
countdown();