2012-07-16 253 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();