我的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文件之后......这就是我所得到的:
我正在寻找以下格式
有什么建议吗?再次感谢你!!
答案 0 :(得分:3)
你走了,
$('.month_year').datepicker({
format: 'MM yy',
viewMode: "months", //this
minViewMode: "months",//and this
//autoClose:true
});
<强> DEMO 强>
您还可以使用startView
的{{1}}个实例并设置选项..