问题描述
这里有关于配置(以及如何使用)此插件的说明:
There are instructions to configure (and how to use) this plugin here:http://www.jqueryscript.net/time-clock/Modern-Circular-jQuery-Countdown-Timer-Plugin-Final-Countdown.html
首先,我不知道这些数字是什么意思......它甚至没有解释。我推断他们的意思是秒。
First off, I don't know what those numbers mean... it's not even explained. I deduce they mean seconds.
所以我这样设置我的代码:
So I set my code this way:
$('.countdown').final_countdown({
'start': 0, /* ((((Jan + Feb + 3 days) * number of hours in a day) * number of minutes in an hour) * number of seconds in a minute) = total seconds */
'end': ((((31+28+31+2)*24)*60)*60), /* started at 9:25 pm on March 03 */
'now': ((((31+28+3)*24)*60)*60),
seconds: {
borderColor: '#8ef58e',
borderWidth: '9'
},
minutes: {
borderColor: '#ff8d72',
borderWidth: '9'
},
hours: {
borderColor: '#69ccff',
borderWidth: '9'
},
days: {
borderColor: '#ffd35c',
borderWidth: '9'
}
});
问题在于,每次加载页面时,都显示相同的29天。该脚本没有抓住当前时间/日期并与未来的其他时间/日期进行比较。
The problem is that every time one loads the page, it shows the same 29 days. The script is not grabbing the current time/date and comparing with another time/date in the future.
所以它现在看起来不错(29天),但是几天从现在开始有人会加载这个页面,它将完全关闭。
So it looks okay now (29 days), but a few days from now someone will load this page and it will be totally off.
你可以在这里看到脚本(和问题):
You can see the script (and issue) here:http://www.3rd-dimension.co
我非常感谢对此有任何帮助。
I greatly appreciate any help on this.
推荐答案
问题是您的现在值是固定值(例如,'now':((((31 + 28 + 3)* 24)* 60)* 60),
)。
The problem is that your 'now' value is a fixed value (eg. 'now': ((((31+28+3)*24)*60)*60),
).
相反,您应该动态获取现在值,使用JavaScript的原生新的Date()
,如下所示:
Instead, you should get your 'now' value dynamically, with JavaScript's native new Date()
, as shown below:
// We will get the "now" value from this variable
var today = new Date();
// My target date is this month 30th 9.25pm
var target = new Date(today);
target.setDate(30);
target.setHours(21,25,0,0);;
// Countdown start from yesterday
var yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
yesterday.setHours(0,0,0,0);;
$('.countdown').final_countdown({
'start': yesterday.getTime() / 1000,
'end': target.getTime() / 1000,
'now': today.getTime() / 1000,
seconds: {
borderColor: '#8ef58e',
borderWidth: '9'
},
minutes: {
borderColor: '#ff8d72',
borderWidth: '9'
},
hours: {
borderColor: '#69ccff',
borderWidth: '9'
},
days: {
borderColor: '#ffd35c',
borderWidth: '9'
}
});
请参考小提琴的工作示例:
Please refer to fiddle for working example:http://jsfiddle.net/zeskysee/v0hc6cfj/11/
希望这个帮助:)
这篇关于jquery.final-countdown.js - 需要帮助配置它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!