Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从页面自动添加或删除div_Javascript_Jquery_Html_Countdown - Fatal编程技术网

Javascript 从页面自动添加或删除div

Javascript 从页面自动添加或删除div,javascript,jquery,html,countdown,Javascript,Jquery,Html,Countdown,我怎样才能保证页面上总是有7个分区?我为这个倒计时程序做了编程,现在只有两个,但我会再加上大约30个。我怎样才能保证页面上总是有7个倒计时 示例:一个倒计时完成并自动从页面中删除,另一个倒计时自动添加到底部 <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> </head> <body> <scri

我怎样才能保证页面上总是有7个分区?我为这个倒计时程序做了编程,现在只有两个,但我会再加上大约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;">&nbsp;</h1>

    <div>
    <div id="sati2Box"></div>
    <div id="minute2Box"></div>
    <div id="sekunde2Box"></div>
    </div>

   </center> 
</body>

我可以向您推荐这样的建筑师:

一些带有选项的数组,其中包含每个倒计时的标题和时间 只有一个函数ctdt,它从setInterval而不是setTimeout运行 具有间隔ID的数组 在document.ready上运行一些函数,该函数将使用选项分析数组,获取实际的倒计时,这些倒计时尚未显示在页面上,并根据需要输出尽可能多的项。 当某个倒计时结束时,将其隐藏并运行相同的to doc.ready函数,该函数将显示更多的倒计时(如果可用)。 这不仅仅是一个问题,它需要一些时间来实现,这就是为什么我不能给你完整的workni代码,对不起

祝你好运