【发布时间】:2011-04-29 10:47:57
【问题描述】:
我正在使用 jQuery UI 的日期选择器 (http://docs.jquery.com/UI/Datepicker)。
听起来应该可以通过提供beforeShowDay 函数来标记某些日子 (http://docs.jquery.com/UI/Datepicker#event-beforeShowDay)。但我无法为此获得正确的 CSS。我想让背景变绿几天。
这是我目前拥有的 JavaScript:
$(function() {
$('.date').datepicker({
dateFormat: 'yy-mm-dd',
firstDay: '1',
showOtherMonths: 'true',
beforeShowDay: daysToMark
});
});
function daysToMark(date) {
if (date.getDate() < 15) {
return [true, 'markedDay', ""];
}
return [true, '', ""];
}
这是css:
.markedDay {
background-color: green;
}
但没有任何改变。我做错了什么?
【问题讨论】:
标签: javascript jquery css jquery-ui