仅显示月份和年份不适用于jQuery-2.1.1
问题描述:
我的datepicker与jQuery-1.9.1完美配合。仅显示月份和年份不适用于jQuery-2.1.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是该的jsfiddle。
但后来我们不得不开始使用jQuery-2.1.1,现在我的datepicker不工作。有人可以帮帮我吗?谢谢!
更新 谢谢“佩卡”作为参考。但即使添加了jQueryUI的文件后,...这是我得到:
而我要找的格式如下
什么建议吗?再次感谢你!!
答
在这里你去,
$('.month_year').datepicker({
format: 'MM yy',
viewMode: "months", //this
minViewMode: "months",//and this
//autoClose:true
});
您还可以使用startView
instad的viewmode
,并设置选项..
+0
任何时候..快乐编码.. :) –
http://*.com/questions/25784944/jquery-datepicker-calendar-does-not-appear检查它 – guradio
在小提琴中你还在使用'jquery-1.9'? –
您正在寻找'bootstrap datepicker'? –