jquery datepicker css样式设置禁用日期

jquery datepicker css样式设置禁用日期,jquery,css,jquery-ui-datepicker,Jquery,Css,Jquery Ui Datepicker,我正在尝试将Jquery datepicker与MySQL数据库一起使用,以显示任何具有事件的日期 由于偏好,我设置了showOtherMonths:true 我想做的是样式的残疾日期是在当前的一个月,所以他们不是在其他月份的日期相同的颜色 我如何为这个添加样式 $(document).ready(function() { var selected_dates = new Array(); // get all the events from the database usin

我正在尝试将Jquery datepicker与MySQL数据库一起使用,以显示任何具有事件的日期

由于偏好,我设置了showOtherMonths:true

我想做的是样式的残疾日期是在当前的一个月,所以他们不是在其他月份的日期相同的颜色

我如何为这个添加样式

$(document).ready(function() 
{
    var selected_dates = new Array();
    // get all the events from the database using AJAX
    selected_dates = getSelectedDates();

    $('#datepicker').datepicker({
        dateFormat: 'yy-m-d',
        inline: true,
        showOtherMonths: true,
        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        beforeShowDay: function (date)
        {
            // get the current month, day and year
            // attention: the months count start from 0 that's why you'll need +1 to get the month right
            var mm = date.getMonth() + 1, 
                dd = date.getDate(),    
                yy = date.getFullYear();
            var dt = yy + "-" + mm + "-" + dd;

            if(typeof selected_dates[dt] != 'undefined')
            {
                // put a special class to the dates you have events for so you can distinguish it from other ones
                // the "true" parameter is used so we know what are the dates that are clickable
                return [true, " my_class"];
            }

            return [false, ""];
        }           
    });
});

您可以使用cssdef

.ui-datepicker-other-month.ui-state-disabled:not(.my_class) span{
    color: red;    
}

演示:

我将下面的代码添加到custom Style.css中,它就像一个符咒

.ui-datepicker-unselectable .ui-state-default {
    background: yellow;
    color: red;
}

谢谢你,阿伦。我只是拿出:not(.my_class)并改了背景色,得到了我想要的结果。正如gibberish所问,你从哪里得到的信息,因为我需要做更多的造型?