【发布时间】:2015-09-30 15:00:08
【问题描述】:
我使用 jquery ui datepicker,我想根据时间数组为一天着色一个框。问题是我想在不同的日子添加颜色,而不必创建所有 css 类,只需添加十六进制颜色。这是我的代码:
$('.datepicker').datepicker({
changeMonth: true,
changeYear: true,
beforeShowDay: function (date) {
var month = date.getMonth()+1;
var day = date.getDate();
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
return [true, $.inArray(the_day, tab_days) >= 0 ? "odd" : ''];
}
});
Css 类:
.odd a.ui-state-default {
color:white;
background-color: red;
background: red;
}
这个版本有效,但每天都有相同的颜色,我会这样做:
$(this).css("background-color", hexa color);
【问题讨论】:
标签: javascript jquery css jquery-ui datepicker