Jquery UI 日期选择器更改一天的背景颜色

发布于 2024-12-19 22:53:40 字数 577 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

讽刺将军 2024-12-26 22:53:40

hii 我自己找到了它,

我只是修改了 css,如下所示,它工作得很酷:)

.odd a.ui-state-default {color:white;
                         background-color: red;
                         background: red;}

谢谢大家:)

hii All I found it myself,

I just modifed the css as given below and it works cool :)

.odd a.ui-state-default {color:white;
                         background-color: red;
                         background: red;}

thank u all :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文