以下代码禁用了某些日期,并突出显示了jQuery DatePicker UI中的其他日期。
var disabledDays = ["2013-12-14", "2014-1-21", "2014-1-24", "2011-7-27", "2014-1-28"];
var date = new Date();
jQuery(document).ready(function () {
$(".dp").datepicker({
buttonImage: 'images/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
showOn: 'both',
beforeShowDay: function (date) {
var m = date.getMonth(),
d = date.getDate(),
y = date.getFullYear();
for (i = 0; i < disabledDays.length; i++) {
if ($.inArray(y + '-' + (m + 1) + '-' + d, disabledDays) != -1) {
return [true, 'ui-state-active', ''];
}
}
return [false];
}
});
});
如何在JavaScript中实现相同的代码?
SlickGrid DatePicker在这里找到:
slickgrid datepicker example