如何让页面上总共有7个div(倒计时)?我编程这个倒计时,现在只有2个,但我会增加约30个。如何让页面上总共有7个倒计时。
示例:一个倒计时结束并自动从页面中删除,另一个倒计时自动添加到底部。
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
<script>
var d = new Date();
var n = d.getDay();
if(n == 1 || 2 || 3 || 4 || 5){
var timer1;
function cdtd1() {
var sad1 = new Date();
var dolazak1 = new Date(sad1.getFullYear(),sad1.getMonth(),sad1.getDate(),14,52,00);
var timeDiff1 = dolazak1.getTime() - sad1.getTime();
if (timeDiff1 <= 0) {
clearInterval(timer1);
$('#dani1Box').remove();
$('#sati1Box').remove();
$('#minute1Box').remove();
$('#sekunde1Box').remove();
}
var sekunde1 = Math.floor(timeDiff1 / 1000);
var minute1 = Math.floor(sekunde1 / 60);
var sati1 = Math.floor(minute1 / 60);
var dani1 = Math.floor(sati1 / 24);
sati1 %= 24;
minute1 %= 60;
sekunde1 %= 60;
$("#dani1Box").html(dani1);
$("#sati1Box").html('7-Dubrava ' + sati1 + ':');
$("#minute1Box").html(minute1 + ':');
$("#sekunde1Box").html(sekunde1);
timer1 = setTimeout(cdtd1, 1000);
}
$(document).ready(function() {
cdtd1();
});
var timer2;
function cdtd2() {
var sad2 = new Date();
var dolazak2 = new Date(sad2.getFullYear(),sad2.getMonth(),sad2.getDate(),23,45,00);
var timeDiff2 = dolazak2.getTime() - sad2.getTime();
if (timeDiff2 <= 0) {
clearInterval(timer2);
$('#dani2Box').remove();
$('#sati2Box').remove();
$('#minute2Box').remove();
$('#sekunde2Box').remove();
}
var sekunde2 = Math.floor(timeDiff2 / 1000);
var minute2 = Math.floor(sekunde2 / 60);
var sati2 = Math.floor(minute2 / 60);
var dani2 = Math.floor(sati2 / 24);
sati2 %= 24;
minute2 %= 60;
sekunde2 %= 60;
$("#dani2Box").html(dani2);
$("#sati2Box").html('6-Sopot ' + sati2 + ':');
$("#minute2Box").html(minute2 + ':');
$("#sekunde2Box").html(sekunde2);
timer2 = setTimeout(cdtd2, 1000);
}
$(document).ready(function() {
cdtd2();
});
}
</script>
<style type="text/css">
#dani1Box, #sati1Box, #minute1Box, #sekunde1Box, #dani2Box, #sati2Box, #minute2Box, #sekunde2Box{
font-size:70px;
color:#1f62a7;
font-family:Sans-serif;
display: inline-block;
}
</style>
<center>
<div>
<div id="sati1Box"></div>
<div id="minute1Box"></div>
<div id="sekunde1Box"></div>
</div>
<h1 style="font-family:Helvetica;color:#FFFFFF;font-size:15px;"> </h1>
<div>
<div id="sati2Box"></div>
<div id="minute2Box"></div>
<div id="sekunde2Box"></div>
</div>
</center>
</body>
答案 0 :(得分:0)
我可以向你推荐这样的建筑师:
这只是一个问题,需要一些时间来实现,这就是为什么我不能给你完整的workni代码,抱歉。
祝你好运!