As isJustMe mentioned, this is just a way to do this. Heres a version with a little addon, which I find quite useful. If you click on the days of the next or previous month, the datepicker function will automatically switch to this month:
jQuery( '#datepicker' ).datepicker( {
showOtherMonths: true,
selectOtherMonths: true,
onSelect: function( string, element ) {
var day = element.selectedDay;
var mon = element.selectedMonth;
var year = element.selectedYear;
var target = jQuery( element.dpDiv ).find( '[data-year="'+year+'"][data-month="'+mon+'"]' ).filter( function() {
return jQuery(this).text().trim() == day;
} );
if( target.hasClass( 'ui-datepicker-other-month' ) ) {
if( parseInt( target.text().trim() ) > 15 ) {
jQuery( element.dpDiv ).find( '.ui-datepicker-prev' ).click();
} else {
jQuery( element.dpDiv ).find( '.ui-datepicker-next' ).click();
}
}
},
} );
adeneo .