简体   繁体   English

带有日期和年份的jQuery datepicker

[英]jquery datepicker with month and year

HTML: HTML:

Start Date: <input type="text" name="startDate" id="datepicker6" value="" />

Jquery: jQuery:

<script type="text/javascript">
$(function(){
    $("#datepicker6").datepicker({
        dateFormat: 'M-y',
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        onClose: function(dateText, inst) 
        {
            $(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay));
        }
    });
});

My current output for the datepicker: 我当前的日期选择器输出:
在此处输入图片说明

Below are my questions: 以下是我的问题:
(1) (1)
I want to hide the calendar using div tag. 我想使用div标签隐藏日历。 And I tried like below and doesn't hide the calendar. 而且我尝试了以下操作,但没有隐藏日历。 How should I hide the calendar in start date? 如何在开始日期中隐藏日历?

<style>
#datepicker6 .ui-datepicker-calendar {
    display: none;
}
</style>

(2) (2)
在此处输入图片说明
Refer to above image, Let's say I choose Apr 2012 on the datepicker, after that I want change Aug 2012, I want to set the Apr 2012 on the drop down list rather than Dec 2015. How should I set it? 参考上面的图片,假设我在日期选择器中选择了2012年4月,之后我想更改2012年8月,我想将2012年4月设置为下拉列表,而不是2015年12月。我应该如何设置它?

According to http://www.hongkiat.com/blog/jquery-ui-datepicker/ , 根据http://www.hongkiat.com/blog/jquery-ui-datepicker/

The calendar dates are wrapped within td or table data. 日历日期包含在td或表数据中。 [And, can be formatted using CSS] [而且,可以使用CSS格式化]

I believe this code should work: 我相信这段代码应该可以工作:

.ui-datepicker tbody td {
    visibility: hidden;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM