【发布时间】:2020-01-26 03:29:16
【问题描述】:
我正在使用日期选择器在我的商店中提取日历。
但是,我遇到了问题。
我正在尝试阻止特定日期,并让日历在特定时间后移至第二天。
我试试下面的代码
jQuery(function($){
$("#attrib-11-0").datepicker({minDate: new Date().getHours() >= 13 ? 1 : 0});
//replace these with the id's of your datepickers
$("#attrib-11-0").datepicker({
beforeShowDay: function(date){
var disabledDays = ["10-2-2020", "11-2-2020","12-2-2020","13-2-2020","14-2-2020"];
var day = date.getDay();
var string = jQuery.datepicker.formatDate('d-m-yy', date);
var isDisabled = ($.inArray(string, disabledDays) != -1);
//day != 0 disables all Sundays
return [day != 0 && !isDisabled];
}
});
不幸的是,它不起作用。
如果我删除它,日期会被正确阻止。如果我把它留在里面,日历会在指定时间后转到第二天,但日期和星期日不会被阻止。
$("#attrib-11-0").datepicker({minDate: new Date().getHours() >= 13 ? 1 : 0});
我做错了什么?
【问题讨论】:
标签: javascript jquery datepicker