想要禁用两周而不是星期日和星期六

Want to Disable two week days instead of Sunday and Saturday

<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/

disableDayFn内部使用||(OR)运算,如图所示:-

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

DEMO

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

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

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

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

//your disabledDayFn
disableDayFn: function(date){
    return disabledDays.includes(date.getDay)
}