这是我的代码
var dates = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(ViewData["ph"]));
$('#StartDate').datepicker({
format: 'dd-M-yyyy',
autoclose: true,
beforeShowDay: function (date) {
for (var i = 0; i < dates.length; i++) {
if (new Date(dates[i]).toString() == date.toString()) {
return [true, 'ui-state-highlight'];
}
}
return [true];
}
});
答案 0 :(得分:0)
您可以通过CSS执行此操作:
.ui-state-highlight {
border-color: red;
}
一个例子:
var dtNow = new Date();
function addDays(d) {
return d * 86400000;
}
function showMyDate(d) {
return d.getDate() + (d.getMonth() + 1) + d.getFullYear();
}
var dates = [
new Date(dtNow.getTime() + addDays(5)),
new Date(dtNow.getTime() + addDays(10)),
new Date(dtNow.getTime() + addDays(12)),
];
$(function() {
$("#datepicker").datepicker({
format: 'dd-M-yyyy',
autoclose: true,
beforeShowDay: function(date) {
var status = [];
$.each(dates, function(key, myDate) {
if (showMyDate(myDate) === showMyDate(date)) {
status = [true, 'ui-state-highlight highlight-red', ''];
} else {
status = [true, '', ''];
}
});
return status;
}
});
});
在此示例中,我添加了两个类:ui-state-highlight
和highlight-red
。这样我就可以直接改变那些需要变红的东西。
<强> CSS 强>
td.ui-state-highlight.highlight-red {
border-color: red;
}