[英]jquery-ui-datepicker update only first input
我正在嘗試創建1個或2個或更多個datepicker。
我創建了一個jquery代碼來執行此操作,但是當執行腳本時,兩個輸入元素都打開了一個日期選擇器,但是只有第一個被更新。
當我單擊第二個日期選擇器時,第一個輸入被編輯。 有什么幫助嗎?
那是jQuery代碼:
$(".datepicker" ).each(function (){
var max = "+0";
if(typeof($(this).data('limit')) != 'undefined'){
max = $(this).data('limit');
}
$(this).datepicker({
yearRange: '-100:'+max,
dateFormat: "dd-mm-yy",
maxDate: max,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
});
});
謝謝!
看看這是否行得通。
$(".datepicker" ).datepicker({
yearRange: '-100:'+max,
dateFormat: "dd-mm-yy",
maxDate: function(){
// do some logic here and return max
var max = "+0";
if(typeof($(this).data('limit')) != 'undefined'){
max = $(this).data('limit');
}
return max;
},
showButtonPanel: true,
changeMonth: true,
changeYear: true,
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.