0

你好,我這裏有一個按鈕,點擊時顯示日曆:jQuery UI的日期選擇更改按鈕

enter image description here

enter image description here

我想實現的是,當日期被挑中,按鈕文字和圖像將被替換爲例如22-07-2016,到目前爲止沒有改變它的運氣。

<input name="depart" id="depart"> 

$("#depart").datepicker({ 
defaultDate: null, 
dateFormat: "dd-mm-yy", 
showOn: "button", 
buttonText: "<span class='glyphicon glyphicon-calendar'></span>Depart<span class='glyphicon glyphicon-menu-down'></span>", 
}); 

我已經嘗試了各種方法,例如:

onSelect: function(date) { 
     buttonText: date, 
}, 
+0

而不是修改buttonText var,你試過在jquery中選擇你的按鈕,並替換文本? –

+0

這不是一個按鈕,它是一個,所以我不能添加文本。 –

回答

1

您必須使用來設置選項的值。 嘗試,

onSelect: function(date) { 
    $(this).datepicker('option', 'buttonText', date); 
},