jQuery datepicker始终具有默认(selectet!)日期(.ui-datepicker-current-day)。如果未设置,则使用当前日期。
我可以通过以下方式清除连接的输入字段:$("#datepicker").datepicker("setDate", null);
但这不会从日历中删除.ui-datepicker-current-day
。
在加载时手动删除该类,可在第一个视图中使用。但是当您更改月份并返回时,当前日期将突出显示为再次选中。
有一些旧的错误报告:
但是我仍然找不到有用的解决方案!
这是一个片段:
$(function() {
$("#datepicker").datepicker({altField: "#date"});
// remove default date
$("#datepicker").datepicker("setDate", null);
// remove current-day class (because default date is still highlighted)
$("#datepicker").find(".ui-datepicker-current-day").removeClass("ui-datepicker-current-day");
});
.ui-datepicker-current-day a {
background-color: red !important;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
DATE:<input disabled="disabled" id="date" name="date" type="text">
<div id="datepicker"></div>
答案 0 :(得分:0)
所以我想我已经按照您的意图实现了,并取消了今天的重点。 我已经使用CSS从正常日期使用样式覆盖突出显示类。
$(function() {
$("#datepicker").datepicker({altField: "#date"});
// remove default date
$("#datepicker").datepicker("setDate", null);
// remove current-day class (because default date is still highlighted)
$("#datepicker").find(".ui-datepicker-current-day").removeClass("ui-datepicker-current-day");
});
.ui-datepicker-current-day a {
background-color: red !important;
}
a.ui-state-default.ui-state-highlight {
border: 1px solid #c5c5c5;
background: #f6f6f6;
font-weight: normal;
color: #454545;
}
a.ui-state-default.ui-state-highlight.ui-state-active {
border: 1px solid #c5c5c5 !important;
background: #f6f6f6 !important;
font-weight: normal !important;
color: #454545 !important;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
DATE:<input disabled="disabled" id="date" name="date" type="text">
<div id="datepicker"></div>