jQuery datepicker仅显示年月

Fab*_*bio 4 jquery jquery-ui jquery-ui-datepicker

我使用datepicker只选择年月.我过滤掉那天的部分:

$(el).datepicker( 
{changeMonth: true, 
changeYear: true, 
dateFormat:'yymm' } 
); 
Run Code Online (Sandbox Code Playgroud)

代码来自jqGrid中的dataInit选项.当用户在一天中点击时,仅将年月传递回输入框.

有没有办法只显示几天的日子?

谢谢.

Len*_*rri 8

这段代码对我来说完美无缺:

$(function()
{   
    $(".monthPicker").datepicker({
        dateFormat: 'MM yy',
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,

        onClose: function(dateText, inst) {
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).val($.datepicker.formatDate('MM yy', new Date(year, month, 1)));
        }
    });

    $(".monthPicker").focus(function () {
        $(".ui-datepicker-calendar").hide();
        $("#ui-datepicker-div").position({
            my: "center top",
            at: "center bottom",
            of: $(this)
        });
    });
});

<label for="month">Month: </label>
<input type="text" id="month" name="month" class="monthPicker" />
Run Code Online (Sandbox Code Playgroud)