请查看我的Sample Fiddle。
我安装了jQuery Countdown计时器。它嵌套在手风琴菜单中。
每支手风琴都应该有一个不同的计时器。只有当我用一架手风琴时它似乎才有效。一旦我将代码置于多个手风琴下,它只接受来自最后一个计时器的数据。
我试图在每个人之下得到一个。你能把我推向正确的方向吗?此正文脚本调用函数:
//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);
}
}
...我总共制作了四个,然后将天数改为days2,days3,days4,并对其他变量做了同样的...
我是在正确的轨道上吗?
答案 0 :(得分:0)
//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';
//------------------------
为什么这个大块在体内?它们可能在您的主脚本之后执行。 您应该按照您希望它们执行的顺序将脚本放在头部。