请查看我的Sample Fiddle。
我安装了一个 jQuery 倒数计时器。它嵌套在手风琴菜单中。
每个手风琴下面应该有一个不同的计时器。只有当我把它放在一架手风琴下时,它似乎才有效。一旦我将代码放在多个手风琴下,它只接受来自最后一个计时器的数据。
我正试图在每个下面得到一个。你能把我推向正确的方向吗?
此正文脚本调用该函数:
//Give the date ---------------------------------
year = 2013; month = 09; day = 27;
//Give the point of time ------------------------
hour= 0; min= 0; sec= 0;
//Standard text ---------------------------------
main_titel= 'Next Start Date - Thursday, October 3, 2013';
//-----------------------------------------------
此脚本包含以下功能:
function GetCount(){
dateNow = new Date();
amount = dateFuture.getTime() - dateNow.getTime()+5;
delete dateNow;
/* time is already past */
if(amount < 0){
out=
"<div id='days'><span></span>0<div id='days_text'></div></div>" +
"<div id='hours'><span></span>0<div id='hours_text'></div></div>" +
"<div id='mins'><span></span>0<div id='mins_text'></div></div>" +
"<div id='secs'><span></span>0<div id='secs_text'></div></div>" ;
document.getElementById('countbox').innerHTML=out;
}
/* date is still good */
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000); /* kill the milliseconds */
days=Math.floor(amount/86400); /* days */
amount=amount%86400;
hours=Math.floor(amount/3600); /* hours */
amount=amount%3600;
mins=Math.floor(amount/60); /* minutes */
amount=amount%60;
secs=Math.floor(amount); /* seconds */
out=
"<div id='days'><span></span>" + days +"<div id='days_text'></div></div>" +
"<div id='hours'><span></span>" + hours +"<div id='hours_text'></div></div>" +
"<div id='mins'><span></span>" + mins +"<div id='mins_text'></div></div>" +
"<div id='secs'><span></span>" + secs +"<div id='secs_text'></div></div>" ;
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
window.onload=function(){GetCount();}
编辑:更新
到目前为止,我已经把这个脚本放在这里了......
function GetCount(){
dateNow = new Date();
amount = dateFuture.getTime() - dateNow.getTime()+5;
delete dateNow;
/* time is already past */
if(amount < 0){
out=
"<div id='days'><span></span>0<div id='days_text'></div></div>" +
"<div id='hours'><span></span>0<div id='hours_text'></div></div>" +
"<div id='mins'><span></span>0<div id='mins_text'></div></div>" +
"<div id='secs'><span></span>0<div id='secs_text'></div></div>" ;
document.getElementById('countbox1').innerHTML=out;
}
/* date is still good */
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000); /* kill the milliseconds */
days=Math.floor(amount/86400); /* days */
amount=amount%86400;
hours=Math.floor(amount/3600); /* hours */
amount=amount%3600;
mins=Math.floor(amount/60); /* minutes */
amount=amount%60;
secs=Math.floor(amount); /* seconds */
out=
"<div id='days'><span></span>" + days +"<div id='days_text'></div></div>" +
"<div id='hours'><span></span>" + hours +"<div id='hours_text'></div></div>" +
"<div id='mins'><span></span>" + mins +"<div id='mins_text'></div></div>" +
"<div id='secs'><span></span>" + secs +"<div id='secs_text'></div></div>" ;
document.getElementById('countbox1').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
...我总共做了四个,然后将天数更改为第 2 天、第 3 天、第 4 天,并对其他变量执行相同操作...
我在正确的轨道上吗?