我可以在datepicker jquery中设置禁用假日和周末吗?

时间:2017-07-20 08:32:13

标签: javascript jquery html datepicker

我想在jQuery Datepicker中为周末和假期设置禁用。但是,假期来自我的阵容。我尝试创建如下代码。我该怎么办?

    $( function() {
    var holidays = ["2017-01-01","2017-01-28","2017-02-15","2017-03-28","2017-04-14"
                    ,"2017-04-24","2017-05-01","2017-05-11","2017-05-25","2017-06-01"
                    ,"2017-06-25","2017-06-26","2017-06-27","2017-06-28","2017-06-29"
                    ,"2017-06-30","2017-08-17","2017-09-01","2017-09-21","2017-12-01"
                    ,"2017-12-25"
    ];
    $( "#datepicker" ).datepicker({
        beforeShowDay: function(date){

            var datestring = jQuery.datepicker.formatDate('yy-mm-dd', date);
            return [ holidays.indexOf(datestring) == -1 ];
        },
        beforeShowDay: $.datepicker.noWeekends,
        MinDate : '0',
        changeMonth :true,
        changeYear : true,
        yearRange: "c-40:+c+0"
    });
 } );

我该怎么办?提前致谢

0 个答案:

没有答案