2016-08-24 67 views
0

我想交換月份/年選擇元素的日期選擇器中changeYear和changeMonth選項啓用日期選擇器的位置。在jQuery UI中交換月份/年選擇列表的位置日期選擇器

默認情況下,出現順序是月份然後是年份,我希望年份然後是月份。

運行下面的代碼片段,看看爲什麼:

$("#picker").datepicker({ 
 
      maxDate: 'today', 
 
      changeYear: true, 
 
      changeMonth: true, 
 
      minDate: "01/01/1939", 
 
      stepMonths:12, 
 
      yearRange: "1939:" + new Date().getFullYear() 
 
     });
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" /> 
 
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> 
 
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> 
 

 

 
<form> 
 

 

 
    
 
<div><b>How do I swap the month/year select list placement?</b></div> 
 
    
 
Birthdate: <input type="text" name="picker" id="picker" value="" /> 
 
    
 
<ol> 
 
    <li>Click the input above to open the datepicker.</li> 
 
    <li>Click on the month select list to view the select options available.</li> 
 
<li>Notice that it only shows up to the current month? This is confusing to users.</li> 
 
<li>Change the year to any previous one.<li> 
 
<li>Now select a month, they are all there.</li> 
 
<li>In our world of left to right processing, in this case, it makes sense to have the year appear first followed by the month.</li> 
 
</ol> 
 
    
 
</form>

+1

[jQuery Date Picker Pick Year First and Then Month]的可能重複(http://stackoverflow.com/questions/8299266/jquery-date-picker-pick-year-first-and-then-month) – 112g

回答

2

月份和年份簡單地漂浮在右邊與CSS:

.ui-datepicker select.ui-datepicker-month, 
.ui-datepicker select.ui-datepicker-year { float: right; } 

或以重複的答案規定:使用optionshowMonthAfterYear: true

相關問題