簡體   English   中英

在jQuery UI Datepicker中交換月/年選擇列表位置

[英]Swap month/year select list placement in jQuery UI Datepicker

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

默認情況下,出現的順序是月份然后年份,而我想要年份然后月份。

運行下面的代碼片段以查看原因:

 $( "#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> 

只需使用CSS將月份和年份向右浮動:

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

或作為重復的答案提供:使用選項 showMonthAfterYear: true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM