keith wood 倒计时总是显示 0

keith wood countdown always display 0

我正在尝试使用这段代码在网页上实现 Keith Wood 倒计时,代码刚好放在结束正文标记之前:

$(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

知道我遗漏了什么吗?

倒计时显示0是因为它是用空参数创建的,代码:

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

以下代码行(您在其中指定了正确的参数)将不会重新创建倒计时。

我的解决方案是在 jquery.countdown.js 文件之后包含用于区域设置的文件 jquery.countdown-fr.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'
    });
});

Fiddle 这里:https://jsfiddle.net/cu246mh2/.