简体   繁体   中英

jquery datepicker with month and year

HTML:

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

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)
I want to hide the calendar using div tag. 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)
在此处输入图片说明
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?

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

The calendar dates are wrapped within td or table data. [And, can be formatted using CSS]

I believe this code should work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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