使用beforeShow
Event 设置属性numberOfMonths
$('#calendar').datepicker({
//minDate: 0,
changeMonth: true,
dateFormat: "dd/mm/yy",
firstDay: 1,
hideIfNoPrevNext: true,
showAnim: 'slideDown',
showOn: "both",
showOtherMonths: true,
showStatus: true,
//maxDate: '-1d'
beforeShow: function(text, inst){
var next_day = new Date(
inst.selectedYear,
inst.selectedMonth,
inst.selectedDay
);
next_day.setDate(next_day.getDate()+1);
console.log(inst.selectedMonth);
console.log(next_day.getMonth());
if(inst.selectedMonth != next_day.getMonth())
return {numberOfMonths: 2};
else
return {numberOfMonths: 1};
}
}).datepicker("setDate", "+0d" );
演示: http: //jsfiddle.net/Z44PQ/1/,选择11月30日再次打开。