javascript jQuery UI Datepicker - 禁用当前日期但不是突出显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16059192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery UI Datepicker - Disable current date but NOT the highlight
提问by Dumpen
I have the following code which disables the current date by setting minDate to current date + 1:
我有以下代码通过将 minDate 设置为当前日期 + 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.
问题是我想禁用当前日期,但仍然在日历中突出显示它(日期周围的蓝色边框)。
Is there a native way to do this using the datepicker or do I have to create a highlight script myself?
是否有使用日期选择器的本地方法来执行此操作,还是我必须自己创建高亮脚本?
采纳答案by Dumpen
The datepicker has a class on todays date called "ui-datepicker-today", so I simply added a class to that:
datepicker 在今天的日期有一个名为“ui-datepicker-today”的类,所以我简单地添加了一个类:
$(".ui-datepicker-today span").addClass("ui-state-hover")
回答by Bobby
you don't need to set today and tomorrow as a variable. just set minDate: 1
您不需要将今天和明天设置为变量。刚刚设置minDate: 1