Jquery日期选择器年份订单

我在这里有一个Jquery日期选择器的代码

// Datepicker from jQuery UI plugin $birth.datepicker({ onSelect: function(dateText, inst) { $(this).parent().find("label#error").html(""); $gender.focus(); }, yearRange: '1950:2006', changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true, dateFormat: 'yy-mm-dd' }); }); 

我的一年下降开始于1950年,一直到2006年,我想扭转它们。

我试过yearRange: '2006:1950'但没有显示:(

有没有办法来解决这个问题?

提供的链接是一个很好的解决方案。 这是另一种方式,但是有点工作: http : //plnkr.co/edit/sSdUbqd1pWKyiBOZAMwD?p = preview

 $(document).ready(function() { var showPicker = false; $("#txtBirthday").datepicker({ onSelect: function(dateText, inst) { $(this).parent().find("label#error").html(""); $gender.focus(); }, yearRange: '1950:2006', changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true, dateFormat: 'yy-mm-dd', onClose: function(dateText, inst) { showPicker = false; } }); $(".ui-datepicker").on("mouseenter", function() { if (!showPicker) { showPicker = true; //Reverse the years var dropYear = $("select.ui-datepicker-year"); dropYear.find('option').each(function() { dropYear.prepend(this); }); } }); }); 

希望这一切,我找到了一个更好的解决方案,并遇到了你的post。 如果这仍然相关:

jQuery datepicker年份下拉列表从1900年开始,我希望它从底部开始

这就是我解决问题的方法。 我认为这就是为什么jQuery没有修复这个“Bug”的原因,因为有一种方法可以让这一年从最后一个日期开始:

 dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-70:", maxDate: "-13Y" 

与我在这里发布的原始代码相比,如果使用yearRange作为固定年份yearRange: "1900:-13" ,最好从下到上使用它: "-70:" 。 并设置maxDate 。 所以现在我从2004年开始我的年份选择框,而不是1900年。

希望这有助于其他人。

PS:所有其他解决方案都经过测试。 它们非常慢,有些不能很好地工作(特别是旧的 – 例如当前年份而不是2004年)。