0
<input id="datepicker">

    var picker = new Pikaday({
    disableDayFn: function(date){
        // Disable Monday
        return date.getDay() === 1;
    },
    field: document.getElementById('datepicker')
});

目前上面的代码禁用了一天,我希望它禁用两天。请帮我整理一下

示例:JsFiddle:http: //jsfiddle.net/jpwk4wpv/

4

3 回答 3

2

在里面使用||(OR)操作disableDayFn,如图所示:-

var picker = new Pikaday({
    disableDayFn: function(date){
        // Disable Monday and Tuesday
        return (date.getDay() === 1 || date.getDay() === 2);
    },
    field: document.getElementById('datepicker')
});

演示

于 2016-04-19T11:20:13.593 回答
1

您必须使用 || 禁用两天 像这样:

var picker = new Pikaday({
disableDayFn: function(date){
    // Disable Monday
    return date.getDay() === 1 || date.getDay() === 2;
},
field: document.getElementById('datepicker')
});
于 2016-04-19T11:22:00.563 回答
0

或者...传入一个禁用天数的数组

// disabled days array
var disabledDays = [1,2]

//your disabledDayFn
disableDayFn: function(date){
    return disabledDays.includes(date.getDay)
}
于 2020-10-21T10:42:21.373 回答