我想添加一個「重置」控件到日曆底部的日期選擇器 - 「關閉」控件的位置。這將使用戶能夠將與datepicker綁定的輸入重置爲空(無日期)。JQuery datePicker date reset
我不知道如何編寫綁定函數,具體來說,我該如何獲得綁定到控件的元素的持有?
if (this.displayClear) {
$pop.append(
$('<a href="#" id="dp-clear">' + $.dpText.TEXT_CLEAR + '</a>')
.bind(
'click',
function()
{
c.clearSelected();
//help! reset the value to '': $(this.something).val('')
c._closeCalendar();
}
)
);
}
在[本討論]中有一些有用的答案(http://bugs.jqueryui.com/ticket/3999)。具體請參見[pfurbacher的示例實現](http://jsbin.com/ofare/edit)。 – Ori 2011-02-07 03:49:55
可能的重複[如何清除/重置jQuery UI Datepicker日曆上的選定日期?](http://stackoverflow.com/questions/9435086/how-do-i-clear-reset-the-selected-dates -jquery-ui-datepicker-calendar) – freemanoid 2015-04-10 19:58:19