在 jQuery datepicker 中更改月份和年份之间的位置

naa*_*ace 1 jquery calendar jquery-ui datepicker

我按照以下链接使用日期选择器制作了“月历”。当我点击按钮时,日历出来并显示月份年份。这是我的问题。有谁知道怎么改这个顺序?

1.month 2.year1.year 2.month

http://develop-for-fun.blogspot.kr/2013/08/jquery-ui-datepicker-month-and-year.html

        $(function () {
            $('#MainContent_txtMonth').datepicker({
                changeYear: true,
                changeMonth: true,
                showButtonPanel: true,
                dateFormat: 'yy-mm',
                monthNamesShort: ['1?','2?','3?','4?','5?','6?','7?','8?','9?','10?','11?','12?'],
                showOn: "button",
                buttonImage: "img/button_calendar.jpg",
                buttonImageOnly: true
                }).focus(function() {
                var thisCalendar = $(this);
                $('.ui-datepicker-calendar').detach();
                $('.ui-datepicker-close').click(function () {
                var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                thisCalendar.datepicker('setDate', new Date(year, month, 1));
                });
            });
        });
Run Code Online (Sandbox Code Playgroud)

Cos*_*min 5

You don't have to modify jquery ui source code. I've just found an options that does what you want.

showMonthAfterYear:true,
Run Code Online (Sandbox Code Playgroud)

Example of usage:

$( "#datepicker" ).datepicker({
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        showMonthAfterYear:true,
        dateFormat: 'MM yy',
      });
Run Code Online (Sandbox Code Playgroud)