其他倒计时后启动倒计时

时间:2018-06-05 13:50:19

标签: jquery

我的页面上有多个倒计时,工作正常!现在我需要在每次倒计时结束后开始一个新的倒计时,但我不知道该怎么做。

我的代码如下:

    function startCountdown (countdownRow) {
      var $this = $(countdownRow);
      var startTime = $this.data('tempsctrl');
      var seconds = 0;
      var timeTokens = startTime.split(':');
      seconds += parseInt(timeTokens[0], 10) * 60 * 60;
      seconds += parseInt(timeTokens[1], 10) * 60;
      seconds += parseInt(timeTokens[2], 10);


      var countdown = setInterval(function() {
        --seconds;

        if (seconds > 0) {
          $this.find('.countdown').html('next control in :'+
                                        formatTime(Math.floor(seconds / 3600)) +':'+ formatTime(Math.floor((seconds % 3600) / 60)) +':'+ formatTime(Math.floor(seconds % 60))
                                       );
        } else {



          $this.find('.countdown').html('');
          $this.find('.restartcount').show();
          $(".restartcount").blink();
          clearInterval(countdown);

          /*###
          HERE I WANT LAUNCH A NEW COUNTDOWN (30 minutes) for this row When the first countdown is end.
example : the first end, the second start a this moment when time is end (30 minuts) an alert show
          ###*/


        }
      }, 1000);

      //attach the interval to the row so we can get it later to restart
      $this.data('countdown', countdown);
    }

    $('[data-tempsctrl]').each(function() {
      startCountdown(this);
    });

我将每个计数的时间设为data-tempsctrl=,新倒计时的时间为data-relance

<tr data-relance="0:30:00" data-tempsctrl="<?php echo $row['tcontrole']; ?>" class="color"> ... </tr>

0 个答案:

没有答案