倒计时翻转时钟并在计数到零后重置

Countdown flipclock and reset after counting to zero

http://flipclockjs.com/

我需要一个从特定时间(例如 2 小时)开始倒数到零的计数器。在这两个小时之后,计时器需要重置并重新启动。

我该怎么做?我在他们的文档中找不到任何相关信息。

我现在得到的:

var clock = $('.your-clock').FlipClock({
  countdown : true,
});

您可以使用方法,参见 'Chainable Methods' 示例。

clock.start(function() {
setInterval(function() {
    clock.stop().reset().start();
}, 7200);

});

我假设你想每秒减少?这是一种非 jquery 方式:

 var counter, myInterval;
    function createCountDown(startHourInSecond){
     counter = startHourInSecond;
     myInterval =window.setInterval(function(){
      counter --;
      if (counter ==0){
      clearInterval(myInterval);
      counter = startHourInSecond;
      createCountDown(counter);
      }
     }, 1000);

    }
createCountDown(7200);

试试这个:

var clock = $('.your-clock').FlipClock({
  countdown : true,
});
clock.setTime(10);
clock.start();
setTimeout(function(){ 
  checktime();
}, 1000);

function checktime(){
  t = clock.getTime();
  if(t<=0){
    clock.setTime(10);
    clock.start();
  }
  setTimeout(function(){ 
    checktime();
  }, 1000);
}