-1

我刚刚下载了这个倒计时脚本(JavaScript),但我不知道如何更改计时器倒计时的日期。原始脚本:

$(function(){
var now = new Date();
// comment out the line below and change the date of your countdown here
var in30Days = new Date( now.getTime() + (30 * 24 * 60 * 60 * 1000) );
// year to countdown to
var countdownYear = in30Days.getFullYear();
// month to countdown to 0 = Jan, 1 = Feb, etc
var countdownMonth = in30Days.getMonth();
// day to countdown to
var countdownDay = in30Days.getDate();

var countdownDate = new Date( countdownYear, countdownMonth, countdownDay );

setupCountdownTimer( countdownDate );

spaceParallax();

hideIphoneBar();

$("[placeholder]").togglePlaceholder();

setupSignupForm();
});
4

2 回答 2

0

也许 countdownDate... 默认情况下它是用 now + 30 天构建的?你可以改变这个。

重要的部分是:

setupCountdownTimer( countdownDate );

spaceParallax();

hideIphoneBar();

$("[placeholder]").togglePlaceholder();

setupSignupForm();
});
于 2013-07-31T08:38:35.187 回答
0

您的代码本身告诉如何做到这一点:

// comment out the line below and change the date of your countdown here
var in30Days = new Date( now.getTime() + (30 * 24 * 60 * 60 * 1000) );
// year to countdown to
var countdownYear = in30Days.getFullYear();
// month to countdown to 0 = Jan, 1 = Feb, etc
var countdownMonth = in30Days.getMonth();
// day to countdown to
var countdownDay = in30Days.getDate();

以下行创建 countDownDate,将年、月和日传递给函数

var countdownDate = new Date( countdownYear, countdownMonth, countdownDay );

setupCountdownTimer( countdownDate );
于 2013-07-31T08:42:18.557 回答