本文介绍了使用Javascript创建倒计时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在搜索中找到了这个来创建一个JavaScript倒计时,但它似乎不适用于我。我很惊讶,因为似乎没有其他人报告有问题。我必须错过一些根本性的东西,我不知道还有什么可以转身,但在这里。

I found this in my search to create a JavaScript Countdown, but it doesn't seem to work for me. I'm surprised, as no one else seems to have reported having a problem. I must be missing something fundamental and I didn't know where else to turn, but here.

下面是JSFiddle上的代码,它对我来说似乎不起作用。

Here is the code live on JSFiddle where it doesn't seem to function for me, either.

function updateWCTime() {
    now      = new Date();
    kickoff  = Date.parse("April 27, 2013 09:00:00");
    diff = kickoff - now;

    days  = Math.floor( diff / (1000*60*60*24) );
    hours = Math.floor( diff / (1000*60*60) );
    mins  = Math.floor( diff / (1000*60) );
    secs  = Math.floor( diff / 1000 );

    dd = days;
    hh = hours - days  * 24;
    mm = mins  - hours * 60;
    ss = secs  - mins  * 60;

        document.getElementById("countdown")
            .innerHTML =
                dd + ' days ' +
                hh + ' hours ' +
                mm + ' minutes ' +
                ss + ' seconds';
}
setInterval('updateWCTime()', 1000 );


推荐答案

将时间间隔更改为(live fiddle:)

Change the interval to (live fiddle: http://jsfiddle.net/96TWk/1/)

setInterval(updateWCTime, 1000 );

控制台说函数 updateWCTime 是没有找到,我不知道为什么。 Cu's好像还好。

The console says that the function updateWCTime is not found, I don't know excactly why. Cu's it seems ok.

这篇关于使用Javascript创建倒计时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 16:47