仅显示不使用jQuery-2.1.1的月份和年份

时间:2015-09-04 03:42:15

标签: jquery jquery-ui twitter-bootstrap-3 bootstrap-datepicker

我的datepicker与jQuery-1.9.1完美配合。

HTML:

<label> Select month & year: </label>
<input name="month" class="month_year" placeholder="mm/yyyy"/>

jQuery的:

    $(function() {
        $('.month_year').datepicker({
            changeMonth: true,
            changeYear: true,
            showButtonPanel: true,
            dateFormat: 'MM yy',
            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).datepicker('setDate', new Date(year, month, 1));
            }
        }).focus(function () {
            $(".ui-datepicker-calendar").hide();
        });
    });

Here是其中的傻瓜。

然后我们不得不开始使用jQuery-2.1.1,现在我的datepicker无效。有人可以帮帮我吗?谢谢!

更新 谢谢你&#34; Pekka&#34;供参考。但即使在添加了jqueryui文件之后......这就是我所得到的:

enter image description here

我正在寻找以下格式

enter image description here

有什么建议吗?再次感谢你!!

1 个答案:

答案 0 :(得分:3)

你走了,

$('.month_year').datepicker({
    format: 'MM yy',
    viewMode: "months", //this
    minViewMode: "months",//and this
    //autoClose:true
});

<强> DEMO

您还可以使用startView的{​​{1}}个实例并设置选项..

相关问题