这与帖子 jQuery UI Datepicker Today Link 相关
使用下面的代码会导致“Today”按钮呈现为黑色。然而,它只能工作一次,因为当单击“今天”按钮时,它会变灰。有没有更好的方法来处理这个问题,使显色性永久存在?
$(document).ready(function() {
$(".datePicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
yearRange: "2000:c+1",
showButtonPanel: true
});
$('.datePicker').click(function () {
$('button.ui-datepicker-current').removeClass('ui-priority-secondary').addClass('ui-priority-primary');
});
});
最佳答案
因为日期选择器只有 beforeShow 事件,而不是 onShow、onOpen 或 afterShow。我们应该自己构建它。
$.datepicker._updateDatepicker_original = $.datepicker._updateDatepicker;
$.datepicker._updateDatepicker = function(inst) {
$.datepicker._updateDatepicker_original(inst);
var afterShow = this._get(inst, 'afterShow');
if (afterShow)
afterShow.apply((inst.input ? inst.input[0] : null));
}
引用:afterShow event on jquery datepicker
如果我们加入你的函数,那就像 this fiddle
关于jQuery 日期选择器 : Prevent the "Today" button from being grayed out,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49164670/