我想知道如何才能禁用下周一,因为现在是周五。 我可以每个星期一禁用,但我只想禁用一个,当天是星期五,并且只有第一个星期一,而不是每个星期一。
我正在使用这个,我进入了 if 循环,但它没有返回任何内容。
minDate: new Date(y,m,fridayNotMonday),
function fridayNotMonday()
{
var vdate = new Date();
var vday = vdate.getDay();
var vm = vdate.getMonth(), vd = vdate.getDate(), vy = vdate.getFullYear();
var vd1 = vdate.getDate() + 2;
var vd2 = vdate.getDate() + 4;
if (vday == 5) {
alert("friday");
firstDate: new Date(vy,vm,vd2);
return firstDate
} else {
firstDate1: new Date(vy,vm,vd1);
return firstDate1;
}
}
最佳答案
您应该使用beforeShowDay
日期选择器的选项
var now = new Date();
var day = now.getDay();
// on the following line 5 means friday. Days start counting from 0=sunday to 6=saturday.
// so if now is friday then find the date of the following monday
var disabled = (day===5)? new Date(now.getFullYear(), now.getMonth(), now.getDate()+3): null;
$('#datepickerelement').datepicker({
beforeShowDay:function(current){
// if the disabled date we calculate is the same as the one the plugin tries to show
// then set its selectable status to false..
if (disabled !== null && disabled.getTime() === current.getTime() ) {
return [false];
} else {
return [true];
}
}
});
关于jquery - 日期选择器 - 如何仅禁用一个星期一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12796307/