Jon*_*han 4 jquery jquery-ui datepicker
我过去使用过JQuery UI DatePicker,我很满意.我正在寻找一种方法向用户显示未来的多个日期.我不希望用户能够选择日期,我只想让他们在运行时修复它们.
有没有简单的方法使这成为可能?
Wil*_*Niu 11
你可以用这个beforeShowDay活动做到这一点.
// list of dates to highlight
var dates = [
[2011, 8, 1],
[2011, 8, 9],
[2011, 8, 25]
];
$('#datepicker').datepicker({
beforeShowDay: function (date){
var year = date.getFullYear(), month = date.getMonth(), day = date.getDate();
// see if the current date should be highlighted
for (var i=0; i < dates.length; ++i)
if (year == dates[i][0] && month == dates[i][1] - 1 && day == dates[i][2])
return [false, 'ui-state-highlight ui-state-active'];
return [false];
}
});
Run Code Online (Sandbox Code Playgroud)
参见示例:http://jsfiddle.net/william/VzZYU/