更改 JQuery 日期选择器中禁用日期的颜色
我正在使用 JQuery 来显示日历(日期选择器)。
我很容易地禁用了周末,然后我尝试禁用国庆日。
这是代码示例:
function checkHolidays(date, holidaysArray) {
for (var i = 0; i < holidaysArray.length; ++i) {
if (date.getMonth() == holidaysArray[i][0].getMonth()
&& date.getDate() == holidaysArray[i][0].getDate()) {
return ([false, 'holiday', holidaysArray[i][1]]);
}
}
return [true, ''];
}
这是有效的。但我想更改单元格的颜色(“假日”CSS 属性),但这不起作用。因为我将这一天设置为禁用,所以不会应用假日 css 属性。
但如果我不禁用日期,即:
return ([true, 'holiday', holidaysArray[i][2]]);
css 属性正在工作。有什么想法吗?
编辑:
我已将我的 css 规则更新为:
.holiday, .ui-datepicker .holiday span
{
background: none #FFEBAF;
border: 1px solid #BF5A0C;
}
现在它工作正常。
这篇文章帮助了我:如何更改单元格颜色
I'm using JQuery to display a calendar (datepicker).
I've disabled weekends easily and then I've tried to disable national days.
So here a sample of code:
function checkHolidays(date, holidaysArray) {
for (var i = 0; i < holidaysArray.length; ++i) {
if (date.getMonth() == holidaysArray[i][0].getMonth()
&& date.getDate() == holidaysArray[i][0].getDate()) {
return ([false, 'holiday', holidaysArray[i][1]]);
}
}
return [true, ''];
}
This is working. But I want to change the color of the cell (the 'holiday' css property) and this is not working. Because I'm setting the day as disabled, the holiday css property is not applied.
But if I do not disable the date, i.e:
return ([true, 'holiday', holidaysArray[i][2]]);
The css property is working. Got any idea?
Edit:
I've updated my css rule to:
.holiday, .ui-datepicker .holiday span
{
background: none #FFEBAF;
border: 1px solid #BF5A0C;
}
And now it's working perfectly.
This post helped me: How to change cell color
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会发现这些很有用:
jQuery UI DatePicker:禁用指定日期
jQuery UI:在 jquery datepicker 中突出显示多个日期
禁用日期
You may find these useful:
jQuery UI DatePicker: Disable Specified Days
jQuery UI: Highlight multiple dates in jquery datepicker
Disable date