方法1:
$( "#datepicker" ).datepicker({
showButtonPanel: true,
beforeShow: function( input ) {
setTimeout(function() {
var buttonPane = $( input )
.datepicker( "widget" )
.find( ".ui-datepicker-buttonpane" );
$( "<button>", {
text: "Clear",
click: function() {
$.datepicker._clearDate( input );
}
}).appendTo( buttonPane );
}, 1 );
}
});
方法2:
$(".datepicker").datepicker({
showButtonPanel: true,
closeText: 'Clear',
});
$.datepicker._generateHTML_Old = $.datepicker._generateHTML;
$.datepicker._generateHTML = function(inst) {
res = this._generateHTML_Old(inst);
res = res.replace("_hideDatepicker()","_clearDate('#"+inst.id+"')");
return res;
}
参考资料:
http://bugs.jqueryui.com/ticket/3999