0

我已经尝试了半天来循环这个倒计时功能。我不想创建不同的倒计时。我该如何循环它?请注意,这是一个间隔为 1 秒的倒数计时器。我的网站在这里http://jian.comoj.com/

<script type="text/javascript">

    setInterval('countdown()',1000);

    function countdown(){

        var now = new Date();

        var unix_now= now.getTime()/1000;

        unix_now= Math.floor(unix_now);


        var sec = <?php echo $end_time[0]; ?> - unix_now;


        if(sec<=0){
            clearInterval(stop);

        }



        var min = Math.floor(sec / 60);
        var hour = Math.floor(min / 60);

        hour %= 24;
        min %= 60;
        sec %= 60;

        document.getElementById(0).innerHTML= hour+":"+min+":"+sec;


    }

    setInterval('countdown1()',1000);

    function countdown1(){

        var now = new Date();

        var unix_now= now.getTime()/1000;

        unix_now= Math.floor(unix_now);


        var sec = <?php echo $end_time[1]; ?> - unix_now;


        if(sec<=0){
            clearInterval(stop);

        }



        var min = Math.floor(sec / 60);
        var hour = Math.floor(min / 60);

        hour %= 24;
        min %= 60;
        sec %= 60;

        document.getElementById(1).innerHTML= hour+":"+min+":"+sec;


    }

    setInterval('countdown2()',1000);

    function countdown2(){

        var now = new Date();

        var unix_now= now.getTime()/1000;

        unix_now= Math.floor(unix_now);


        var sec = <?php echo $end_time[2]; ?> - unix_now;


        if(sec<=0){
            clearInterval(stop);

        }



        var min = Math.floor(sec / 60);
        var hour = Math.floor(min / 60);

        hour %= 24;
        min %= 60;
        sec %= 60;

        document.getElementById(2).innerHTML= hour+":"+min+":"+sec;


    }

</script>
4

1 回答 1

0

您还需要放入setInterval倒计时功能。类似于递归调用的东西。

于 2012-05-29T10:27:36.960 回答