参见英文答案 Highlight dates in specific range with jQuery’s datepicker7个 我正在使用jQuery UI来显示内联日期选择器,我有一个开始日期和结束日期.我想强调它们之间的日期. 您可以使用jQuery UI d
我正在使用jQuery UI来显示内联日期选择器,我有一个开始日期和结束日期.我想强调它们之间的日期. 您可以使用jQuery UI datepicker beforeShowDay功能,并在其中检查是否必须根据您的范围突出显示日期.
A function takes a date as a parameter and must return an array with
[0] equal to true/false indicating whether or not this date is
selectable, 07001 equal to a CSS class name or “” for the default
presentation, and [2] an optional popup tooltip for this date. It is
called for each day in the datepicker before it is displayed.
例:
var date1 = new Date(2013, 4, 6);
var date2 = new Date(2013, 4, 17);
$(document).ready(function () {
$('#datepicker').datepicker({
beforeShowDay: function (date) {
debugger
if (date >= date1 && date <= date2) {
return [true, 'ui-state-error', ''];
}
return [true, '', ''];
}
});
});
这是一个工作小提琴:http://jsfiddle.net/IrvinDominin/zz9u4/
