2016-05-03 17 views
0

我試圖實現一個網頁使用此代碼,只是結束標記之前放置在基思·伍德倒計時:基思·伍德倒計時始終顯示0

$(function(){             
     var untilDate = new Date(2016,4,4,8,0); 
     console.log(untilDate.getFullYear() + "-" + untilDate.getMonth() + "-" + untilDate.getDate()); 
     $("#next-departure").countdown($.countdown.regionalOptions["fr"]); 
     $("#next-departure").countdown(
      { 
       until:untilDate, 
       format:'yowdHMS' 
      } 
     ); 
    }); 

在控制檯中沒有錯誤,日期是正確的但...總是顯示: No countdown running enter image description here

有什麼想法我失蹤了?

回答

0

倒計時顯示爲0,因爲它與空參數產生的,該代碼:

$("#next-departure").countdown($.countdown.regionalOptions["fr"]); 

的下面幾行代碼,在其中指定適當的參數,也不會重新倒計時。

我的解決辦法是,以包括區域設置文件jquery.countdown-fr.js,在jquery.countdown.js文件之後:

<script type="text/javascript" src="jquery.countdown-fr.js"></script> 

你可以在這裏找到這個文件:https://github.com/kbwood/countdown/blob/master/jquery.countdown-fr.js

然後,創建用下面的代碼倒計時:

$(function(){ 
    var untilDate = new Date(2016,4,4,8,0); 
    $("#next-departure").countdown({ 
     until:untilDate, 
     format:'YOWDHMS' 
    }); 
}); 

小提琴這裏:https://jsfiddle.net/cu246mh2/

+0

沒關係... Thx ... –