year/month only datepicker inline

不想你离开。 提交于 2019-12-11 05:17:07

问题


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>

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.


回答1:


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.

The best way is to do with CSS, an explicit approach.

.monthPicker .ui-datepicker-calendar {
display: none;
}

JSFiddle

Hope this helps.



来源:https://stackoverflow.com/questions/19502445/year-month-only-datepicker-inline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!