2011-04-25 4 views
2

카운트 다운 타이머을 한 페이지에 넣는 방법, 각 카운트 다운이 다른 시간을 지적하는 것, 물론 페이지 새로 고침에서 다시 설정하지 않는 방법은 무엇입니까?Jquery 페이지에서 여러 번 카운트 다운

거기에 jQuery 해결책이 있는지 궁금합니다.

감사합니다.

+0

체크 [잘라내어 붙여 어느 시점까지 카운트 다운 (http://www.javascriptkit.com/script/script2/count.shtml), 잘라 내기 및 붙이기 어떤 날짜 (다운 - 투 - 더 초)까지 카운트 다운] (http://www.javascriptkit.com/script/script2/count2.shtml) [간단한 자바 스크립트 카운트 다운] (http://www.bellaonline.com/ 기사/art40292.asp), [JavaScript 카운트 다운/카운트 업 타이머/시계/티커 웹 페이지 ] (http://www.hashemian.com/tools/javascript-countdown.htm) 다수 카운트 다운 타이머] (http://www.codingforums.com/showthread.php?t=149460). 행운을 비네. – Bastardo

+0

예. http://keith-wood.name/countdown.html을 참조하십시오. – Eden

+0

[jCounter] (http://devingredients.com/jcounter/)를 사용하여 독립적 인 제어 및 폴백을 사용하여 여러 카운터로 여러 개의 카운트 다운 인스턴스를 실행할 수 있습니다. 이게 네가 찾고 있던거야? – SirCommy

답변

1

이 시도 :

<input type="text" id="but1" /> 
<input type="text" id="but2" /> 
<input type="text" id="but3" /> 
<input type="button" value="start" onclick="timer(1)" /> 
<input type="button" value="start" onclick="timer(2)" /> 
<input type="button" value="start" onclick="timer(3)" /> 
<input type="button" value="stop" onclick="stoptimer(1)" /> 
<input type="button" value="stop" onclick="stoptimer(2)" /> 
<input type="button" value="stop" onclick="stoptimer(3)" /> 


<script type="text/javascript"> 
var counts = []; 
var xs = []; 
for (var i = 1; i < 10; i++) { 
    counts.push(i*2); 
    xs.push(0); 
}; 




function timer(id) 
{ 
    xs[id]=setTimeout("timer("+id+")",1000); 
    counts[id]=counts[id]-1; 
    document.getElementById("but"+id).value=counts[id]; 
    if (counts[id] <1){counts[id]=5;} 
} 

function stoptimer(id) 
{ 
    clearTimeout(xs[id]); 
} 

</script>