问题
I am using jQuery datepicker on my website and I have it set like this:
$( "#datepicker" ).datepicker(
{
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true,
yearRange: "1900:-13"
}
).on('change', function() {
$(this).valid(); // triggers the validation test
// '$(this)' refers to '$("#datepicker")'
});
So my year select bar enables years 1900 and up to 2004.
By default when opening the year selectbox - it starts from 1900 and I have to scroll a lot for a more relevant year.
How can I set my jQuery datepicker to start from 2004 (scrolling up) and not from 1900 (scrolling a lot down)?
Researching this issue leads to old posts (7 years ago) and I might be able to find a more practical solution that works for these days.
回答1:
You can try this option:
$( ".selector" ).datepicker({
currentText: "Now"
});
I think that modifying currenText value you can achieve what you want.
API docs
来源:https://stackoverflow.com/questions/42650410/jquery-datepicker-year-dropdown-starts-from-1900-and-i-want-it-to-start-from-the