【发布时间】:2017-03-10 04:52:06
【问题描述】:
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd',
yearRange: '1800:2100',
onSelect: function(value, ui) {
}
});
$('.yearmonth').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yy-mm',
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));
}
});
.yearmonth .ui-datepicker-calendar {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
Year and Month : <input class="yearmonth" type="text" /><br>
Complete Date : <input class="datepicker" type="text" />
我怎样才能在一个上下文中拥有 2 个日期选择器,它有一个完整的日期,而另一个只有月份和年份?
尝试使用 CSS 隐藏,但我无法确定如何选择仅适用于月份和年份的日期选择器
我想要的是当我点击年月时日历应该被隐藏。
【问题讨论】:
-
你的演示正在运行..我错过了什么?
-
不,我想要的是当我点击年份月份时,日历应该被隐藏。
标签: jquery css datepicker