Jquery UI 日期选择器更改一天的背景颜色
我正在使用 Jquery UI datepicker,并且尝试更改一个月中每一天的背景颜色。
为此,我在 Jquery UI 日期选择器中使用 beforeShowDay 函数。
例如,我试图更改一个月中奇数天的背景颜色,而我的脚本仅更改边框颜色。
我不确定错误在哪里,如何覆盖 Jquery 中的整个背景颜色以达到所需的结果。
请帮忙。
使用的脚本:
$(document).ready(function() {
//$("#datepicker").datepicker();
$("#datepicker").datepicker({ inline: true, beforeShowDay: highlightOdds});
});
function highlightOdds(date) {
return [true, date.getDate() % 2 == 1 ? 'odd' : ''];
}
使用的 CSS:
.odd { background-color: green; }
I am using Jquery UI datepicker and I am trying to change the background color for each day in a month.
For this I am using beforeShowDay function in Jquery UI date-picker.
As an example I am trying to change the background color for odd days in a month and my script changes only border color.
I am not sure where the mistake is, How do I over ride the entire back ground color in Jquery to achieve the desired result.
please help.
Script Used:
$(document).ready(function() {
//$("#datepicker").datepicker();
$("#datepicker").datepicker({ inline: true, beforeShowDay: highlightOdds});
});
function highlightOdds(date) {
return [true, date.getDate() % 2 == 1 ? 'odd' : ''];
}
Css Used:
.odd { background-color: green; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
hii 我自己找到了它,
我只是修改了 css,如下所示,它工作得很酷:)
谢谢大家:)
hii All I found it myself,
I just modifed the css as given below and it works cool :)
thank u all :)