簡體   English   中英

僅下拉菜單中的月份和年份,而jQuery不適用於select

[英]Month and year only in dropdown with jQuery not working on select

我使用datepicker僅將月份和年份作為下拉列表進行選擇。

當我在CSS下面使用禁用datepicker的日期時,它禁用了JSP中的其他datepicker。

1.我怎樣才能使這個CSS內聯到一個所需的日期選擇器?

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

2.禁用一次后,我正在使用onselect選擇不起作用的月份和年份,但是如果我在具有完整日歷的日歷中選擇日期,則可以使用。

$(document).ready(function() {

   $('#txtDate').datepicker({
     changeMonth: true,
     changeYear: true,
     dateFormat: 'M yy',
     yearRange: "-2:+0",
     defaultDate: '-1m',

     onSelect: function() {
        var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").text();
        var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();


        callmymethod();
        }
        });
         });

請幫助我這兩個查詢。 謝謝

我已經為此解決了我的目的

jsfiddler

<input type="text" data-calendar="false" />
<input type="text" data-calendar="false" />
<input type="text" data-calendar="true" />

jQuery的

$('input').datepicker({
    beforeShow: function(el, dp) {
        $('#ui-datepicker-div').toggleClass('hide-calendar',   $(el).is('[data-calendar="false"]'));
    }
});

的CSS

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

暫無
暫無

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

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