0

看到有一些帖子为此但并列但它们似乎不起作用。

var noWeekend = jQuery.datepicker.noWeekends(date);

目前我的代码这样做并使周末活跃,但我希望它做相反的事情并只让周末活跃

知道怎么做吗?

4

2 回答 2

0

本教程似乎完全按照您的描述进行。

于 2013-11-29T16:15:15.000 回答
0
$("#txtDate").datepicker({ beforeShowDay: onlyWeekends});

function onlyWeekends(date) {
    var noWeekend = $.datepicker.noWeekends(date);
    if (noWeekend[0]) {
        return [false, ''];
    } else {
        return [true, ''];
    }
}

从文档:(http://api.jqueryui.com/datepicker/#option-beforeShowDay

*beforeShowDay*

A function that takes a date as a parameter and must return an array with:

[0]: true/false indicating whether or not this date is selectable 
[1]: a CSS class name to add to the date's cell or "" for the default presentation 
[2]: an optional popup tooltip for this date

所以你可以这样返回:

    if (noWeekend[0]) {
        return [false, 'hilite', 'oops, this is a weekday!'];
    } else {
        return [true, 'normal', 'ok to select'];
    }
于 2013-11-29T16:16:33.960 回答