这与post 今日链接jQuery UI数据报警器有关
使用下面的代码将“今天”按钮呈现为黑色。然而,它只工作一次,因为当单击“今日”按钮时,它会回到灰色状态。是否有更好的方法来处理这一点,使颜色呈现是永久的?
$(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');
});
});发布于 2018-03-08 04:15:59
因为datepicker只有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事件
如果我们加入您的函数,这将类似于这把小提琴
https://stackoverflow.com/questions/49164670
复制相似问题