jQuery UI Datepicker - 禁用当前日期,但不显示高亮
问题描述:
我有以下代码通过将minDate设置为当前日期+ 1来禁用当前日期:
I have the following code which disables the current date by setting minDate to current date + 1:
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
$("#minDate").datepicker({
showOn: "none",
minDate: tomorrow,
dateFormat: "DD dd-mm-yy",
onSelect: function(dateText) {
minDateChange;
},
inputOffsetX: 5,
});
问题是我要禁用当前日期,但仍然保持突出显示(蓝色边框周围的日期)在日历中。
The problem is that I want to disable the current date, but still keep it highlighted (Blue border around the date) in the calendar.
有没有一种本机的方法来使用datepicker或者我必须自己创建一个高亮脚本?
Is there a native way to do this using the datepicker or do I have to create a highlight script myself?
答
datepicker在今天的日期里有一个名为ui-datepicker-today的课程,所以我只是添加了一个类:
The datepicker has a class on todays date called "ui-datepicker-today", so I simply added a class to that:
$(".ui-datepicker-today span").addClass("ui-state-hover")