我想添加一个自定义按钮到jQuery的datepicker按钮面板。当我申请下面的代码,但没有任何反应:jQuery datepicker添加自定义按钮
$('.date-picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
beforeShow: function(input) {
setTimeout(function() {
var buttonPane = $(input).datepicker("widget").find(".ui-datepicker-buttonpane");
var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>');
btn.unbind("click").bind("click", function() {
$.datepicker._clearDate(input);
});
btn.appendTo(buttonPane);
}, 1);
} ,
dateFormat: 'MM yy',
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
任何帮助,将不胜感激。
它似乎在此处工作按钮被添加http://jsfiddle.net/HXLk4/6/ – Rafay 2012-03-27 16:53:58
其他格式化消失了。我没有显示日历,只是日期和月份。但都一样,嗅,为什么不适合我? :( – PruitIgoe 2012-03-27 17:09:12
请参阅http://stackoverflow.com/questions/4598850/how-do-you-add-buttons-to-a-jquery-datepicker-in-the-button-panel – RicardoMarquez 2014-01-04 03:03:15