datepicker beforeShowDay vs. selected

时间:2012-09-18 12:52:17

标签: css jquery-ui datepicker

我有一个使用beforeShowDay的特殊高亮显示的日期选择器。但是,突出显示样式会阻止选定的(“ui-btn-active”)样式,该样式在单击单元格时自动应用。将所选风格置于最佳位置的最佳方法是什么?

<div id="datepicker"></div>

.Highlighted a{
background: none !important;
background-color: #990066 !important;
}

        $('#datepicker').datepicker({
            beforeShowDay: function (date) {
                return [true, SelectedDates[date] ? 'Highlighted' : ''];
            }
        });

添加此功能无效:

.Highlighted ui-btn-active a{
background: none !important;
background-color: white !important;
}

2 个答案:

答案 0 :(得分:0)

在您的beforeShowDay代码中,在添加了突出显示的类后,将ui-btn-active类添加到所选元素。

记住元素可以有多个类。

答案 1 :(得分:0)

  beforeShowDay: function (date) {
                var selected = $("#datepicker").datepicker('getDate');
                if (date.getDate() != selected.getDate()) return [true, SelectedDates[date] ? 'Highlighted' : ''];
                else return [true, '']
            }