Jquery 仅适用于工作日的倒数计时器
Jquery countdown timer for week days only
我正在使用 Syotimer jquery 插件(https://github.com/mrfratello/SyoTimer)进行递归倒计时。它正在工作 fine.Currently 我已将其设置为周期性倒计时 2 天。
这是我的代码:
jQuery('#periodic_timer').syotimer({
year: 2016,
month: 1,
day: 30,
hour: 13,
minute: 41,
dayVisible: false,
dubleNumbers: false,
// effectType: 'opacity',
periodUnit: 'd',
periodic: true,
periodInterval: 2,
});
现在我的问题是我需要只在工作日设置定时器,而在周末定时器不工作?
谁可以帮我这个事?这个插件是否提供这样的功能,或者有什么可能的方法可以实现我的要求?
此致,
aton1004
您的功能不一定包含在插件中。您可以确定当前星期几,如果不是周末,只需连接插件即可:
var currentDateTime = new Date(),
currentWeekDay = currentDateTime.getDay();
if ( currentWeekDay != 0 && currentWeekDay != 6 ) {
var syoTimerOptions = {
// put here plugin options
};
jQuery('#periodic_timer').syotimer( syoTimerOptions );
}
P.S.: 方法 getDate() returns 星期几:0 - 星期日,1 - 星期一,...,6 - 星期六
我正在使用 Syotimer jquery 插件(https://github.com/mrfratello/SyoTimer)进行递归倒计时。它正在工作 fine.Currently 我已将其设置为周期性倒计时 2 天。
这是我的代码:
jQuery('#periodic_timer').syotimer({
year: 2016,
month: 1,
day: 30,
hour: 13,
minute: 41,
dayVisible: false,
dubleNumbers: false,
// effectType: 'opacity',
periodUnit: 'd',
periodic: true,
periodInterval: 2,
});
现在我的问题是我需要只在工作日设置定时器,而在周末定时器不工作? 谁可以帮我这个事?这个插件是否提供这样的功能,或者有什么可能的方法可以实现我的要求?
此致, aton1004
您的功能不一定包含在插件中。您可以确定当前星期几,如果不是周末,只需连接插件即可:
var currentDateTime = new Date(),
currentWeekDay = currentDateTime.getDay();
if ( currentWeekDay != 0 && currentWeekDay != 6 ) {
var syoTimerOptions = {
// put here plugin options
};
jQuery('#periodic_timer').syotimer( syoTimerOptions );
}
P.S.: 方法 getDate() returns 星期几:0 - 星期日,1 - 星期一,...,6 - 星期六