簡體   English   中英

帶有日期和年份的jQuery datepicker

[英]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));
        }
    });
});

我當前的日期選擇器輸出:
在此處輸入圖片說明

以下是我的問題:
(1)
我想使用div標簽隱藏日歷。 而且我嘗試了以下操作,但沒有隱藏日歷。 如何在開始日期中隱藏日歷?

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

(2)
在此處輸入圖片說明
參考上面的圖片,假設我在日期選擇器中選擇了2012年4月,之后我想更改2012年8月,我想將2012年4月設置為下拉列表,而不是2015年12月。我應該如何設置它?

根據http://www.hongkiat.com/blog/jquery-ui-datepicker/

日歷日期包含在td或表數據中。 [而且,可以使用CSS格式化]

我相信這段代碼應該可以工作:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM