通过setInterval()在网页上使用多个计时器,并将为每个计时器生成的唯一指针存储在数组中。在每次AJAX调用时,数组都会刷新,指针编号也会增加。我的问题是:使用seInterval / setTimeout可以使javascript指针达到的最大数量是多少,有没有办法将指针数量重置为0?
function countdown(elem,timeToGo,index){
var cdelem = document.getElementById(elem);
var interval = setInterval(function(){
var now = new Date().getTime();
if (timeToGo<=now){
cdelem.innerHTML = "fishished";
clearInterval(tmrsArray[index]);
}
else{
var ttl = timeToGo-now;
var millisecs = parseInt((ttl%1000)/100),
secs = parseInt((ttl/1000)%60),
mins = parseInt((ttl/(1000*60))%60),
hrs = parseInt((ttl/(1000*60*60))%24);
hrs = (hrs<10)?"0"+hrs:hrs;
mins = (mins<10)?"0"+mins:mins;
secs = (secs<10)?"0"+secs:secs;
cdelem.innerHTML = hrs+":"+mins+":"+secs;
}
}, 1000);
tmrsArray[index]=interval;
}