在jQuery datepicker中突出显示一周中的特定日子

在jQuery datepicker中突出显示一周中的特定日子

问题描述:

我的目的是在jQuery datepicker中突出显示一周中的特定日期.

my aim is to highlight specific days of a week in jQuery datepicker.

例如,我要突出显示星期二和星期四.我看过很多示例,这些示例如何突出显示特定日期(请参阅: http://jquerybyexample.blogspot.com/2012/05/highlight-specific-dates-in-jquery-ui.html ).但没有一个可以满足我的需求.

For example I want to highlight Tuesdays and Thursdays. I've seen many examples how to highlight specific dates(see: http://jquerybyexample.blogspot.com/2012/05/highlight-specific-dates-in-jquery-ui.html). But not a single one that covers my needs.

有任何提示吗?

您可以调整链接的示例,以执行所需的操作,如下所示:

You could adapt the example you linked, to do what you want, like this:

CSS:

.Highlighted a{
   background-color : Green !important;
   background-image :none !important;
   color: White !important;
   font-weight:bold !important;
   font-size: 12pt;
}

JavaScript:

Javascript:

$(document).ready(function() {
    $('#datepicker').datepicker({
        beforeShowDay: function(date) {
            var day = date.getDay();
            if (day == 2 || day == 4) {
                return [true, "Highlighted", date];
            }
            return [true, '', ''];
        }
    });
});​

应该这样做.