0

MySQL データベースで Jquery datepicker を使用して、イベントのある日付を表示しようとしています。

好みにより、 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, ""];
        }           
    });
});
4

2 に答える 2

1

CSS定義を使用できます

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

デモ:フィドル

于 2013-09-05T16:10:48.590 に答える