jQuery倒计时器显示0

时间:2016-03-13 04:55:36

标签: jquery html countdown

我正在玩jQuery并且陷入了倒数计时器。到目前为止它运作良好。但是当我运行网站时,它一直显示为0。

这是我的代码:

var now = new Date();
var end = new Date('03/15/2016 10:00:00 PM');
var remaining = end - now;
var countTo = remaining.valueOf();    
//    var countTo = 25 * 24 * 60 * 60 * 1000 + now.valueOf();    
alert(countTo);

$('.timer').countdown(countTo, function(event) {
    $(this).find('.days').text(event.offset.totalDays);
    $(this).find('.hours').text(event.offset.hours);
    $(this).find('.minutes').text(event.offset.minutes);
    $(this).find('.seconds').text(event.offset.seconds);
});

当我使用评论的 countTo 时,整个过程都有效。由于 countTo 都返回TimeStamp,我不明白为什么它不起作用。任何帮助都会非常有帮助。提前谢谢。

1 个答案:

答案 0 :(得分:0)

等待其他人后自己找到解决方案。 现在添加剩余为我做了诀窍。

function requestPermission(){
    cordova.plugins.diagnostic.requestRuntimePermission(function(status){
        switch(status){
            case cordova.plugins.diagnostic.runtimePermissionStatus.GRANTED:
                console.log("Permission granted (or already granted) - call the plugin");
                // call SQLite plugin
                break;
            case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED:
                console.log("Permission denied - ask again");
                alert("Come on user, we really need this. I'll ask again...");
                requestPermission();
                break;
            case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED_ALWAYS:
                console.log("Permission permanently denied");
                alert("Well that's it, we're dead Jim");
                navigator.app.exitApp();
                break;
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    }, cordova.plugins.diagnostic.runtimePermission.READ_PHONE_STATE);
}
requestPermission();

感谢。