问题
I use the feature of selecting a year with a dropdown. I use it to set birthdays of people at least 18 years old. So far it works perfectly. I have set it up using theseg parameters:
$('#datepicker').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy',
minDate: '-100Y',
maxDate: '-18Y'
});
However I'd like to have year navigation. Is it possible to add a next/previous year button?
Thanks in advance for any help!
回答1:
Check this : http://jqueryui.com/demos/datepicker/dropdown-month-year.html its part of datepicker plug in
$(function() {
$('#datepicker').datepicker({
changeMonth: true,
changeYear: true
});
});
回答2:
In order to complete the @PranayRana's answer, jQuery UI gives you the possibility to select the year with the option changeYear, and you are also able to specify the date range to your datepicker (for a birth date field for example).
Here's an example :
$(".datepicker").datepicker({
changeYear: true, // Add the ability to select the year
yearRange: '1930:2000', // Set the year range selection from 1930 to 2000
});
来源:https://stackoverflow.com/questions/3423670/jquery-ui-datapicker-how-to-add-next-previous-year-buttons