年/月只有datepicker内联 [英] year/month only datepicker inline
问题描述
我需要创建一个只显示年份和月份的jquery ui datepiker:
I need to create a jquery ui datepiker that only shows year and month:
$(document).ready(function () {
var montPiker = $(".monthPicker").datepicker({
changeMonth: true,
changeYear: true,
});
$(".monthPicker .ui-datepicker-calendar").hide();
});
<div id="monthPicker" class="monthPicker"></div>
这个想法是有一个月/年的内联选择器,但我遇到的问题是在我改变月份或年份后,再次显示callendar部分。我已经尝试重新应用 .hide()
但我无法找到它应该发生的事件。
the idea is to have a month/year inline picker, but the problem I'm having is that after I change the month or year the callendar part is shown again. I have try to reapply the .hide()
but I can't find on which event should it happend.
任何人都知道,如何解决这个问题?谢谢。
Anyone know, how to solve this? thanks.
推荐答案
在初始化 datepicker $后,实际问题是 c $ c>
,你正在隐藏日历。因此,每当您更改年/月时,日历就会显示。
The actual problem is after initializing the datepicker
, you're hiding the calender. Hence the calender is showing up, whenever you change the year/month.
最好的方法是使用 CSS
,一种明确的方法。
The best way is to do with CSS
, an explicit approach.
.monthPicker .ui-datepicker-calendar {
display: none;
}
JSFiddle
希望这会有所帮助。
JSFiddle
Hope this helps.
这篇关于年/月只有datepicker内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!