【发布时间】:2016-11-08 15:23:52
【问题描述】:
我需要在页面加载时为 jquery 月份选择器设置默认月份和年份。
下面是我的代码。目前加载时月份选择器文本框为空。
$(document).ready(function() {
$('#monthPicker').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: 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));
}
});
});
另外,我需要从日历中删除日期,我的意思是我只需要显示年份和月份选择选项。
【问题讨论】:
-
@Wikiti,它没有多大帮助——您评论中的链接指向这个问题。
-
对不起,我给了这个:stackoverflow.com/questions/3829033/…我的错!
-
@Wikiti 抱歉,我在那里找不到解决问题的方法。
标签: javascript jquery jquery-ui-datepicker