我正在使用此来源http://jqueryui.com/datepicker/#buttonbar的日期选择器,我正试图让#34;今天"按钮栏上的按钮是活跃的,任何人都可以帮助我。
$(".datepicker").datepicker({
showButtonPanel: true, closeText: 'Clear',
gotoCurrent : true,
changeMonth: true,
changeYear: true,
yearRange: '1900, 2300',
dateFormat: _DateFormatDatePicker,
onSelect: function (dateText, inst) {
dateAsString = dateText; //the first parameter of this function
var dateAsObject = $(this).datepicker('getDate'); //the getDate method
document.getElementById('<%=hdnTempDate.ClientID%>').value = dateText;
}
答案 0 :(得分:12)
试试这个:
$(".datepicker").datepicker({
showOn: "button",
showButtonPanel: true,
buttonImage: buttonCalendar,
buttonImageOnly: true,
buttonText: ""
});
并在您拥有日历的页面中调用此js代码。
$.datepicker._gotoToday = function(id) {
$(id).datepicker('setDate', new Date()).datepicker('hide').blur();
};
答案 1 :(得分:9)
试试这个
$(function() {
$( "#datepicker" ).datepicker({
showButtonPanel: true
});
});
答案 2 :(得分:2)
按钮启用按钮面板:showButtonPanel: true
。然后将以下代码放在datepicker JS代码之后:
var _gotoToday = jQuery.datepicker._gotoToday;
jQuery.datepicker._gotoToday = function(a){
var target = jQuery(a);
var inst = this._getInst(target[0]);
_gotoToday.call(this, a);
jQuery.datepicker._selectDate(a, jQuery.datepicker._formatDate(inst,inst.selectedDay, inst.selectedMonth, inst.selectedYear));
};