像这样:jsFiddle示例
$('#dp').datepicker({
beforeShowDay: colorize
});
var blueDates = ['8-5-2013', '8-14-2013', '8-21-2013'];
var greenDates = ['8-15-2013', '8-22-2013'];
var redDates = ['8-9-2013', '8-13-2013'];
function colorize(date) {
mdy = (date.getMonth() + 1) + '-' + date.getDate() + '-' + date.getFullYear();
console.log(mdy);
if ($.inArray(mdy, blueDates) > -1) {
return [true, "blue"];
} else if ($.inArray(mdy, greenDates) > -1) {
return [true, "green"];
} else if ($.inArray(mdy, redDates) > -1) {
return [true, "red"];
} else {
return [true, ""];
}
}