如何更改jQuery Datepicker的单元格颜色 [英] How to change the cell color of a jquery datepicker

查看:107
本文介绍了如何更改jQuery Datepicker的单元格颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jQuery日期选择器,我需要能够更改所选单元格日期的背景色.我正在尝试类似的东西:

I have a jquery datepicker and I need to be able to change the background color for the selected cell date. I'm trying with something like:

    $("#fecha").datepicker({ 
          onSelect: function(value, date) { 
             alert(date.css());
          } 
    });

希望date参数引用所选的单元格,但似乎不起作用.

hoping that the date parameter refers to the selected cell, but it doesn't seem to work.

有什么建议吗?

// 解决方案应该让我动态设置具有不同颜色的不同单元格,这就是为什么我尝试使用onSelect而不是直接更改CSS的原因.

// The solution should let me have different cells with different colors set dynamically, this is why I'm trying with onSelect instead of changing the CSS directly.

目的是创建一个包含由用户建立的事件的日历.

The purpose is to have a calendar with events established by the user.

谢谢.

推荐答案

我认为最好的方法(假设我已经正确理解了您)是简单地覆盖css.
在您的网站样式表或html头部分中,您只需要覆盖以下CSS选择器

I think the best way (assuming i have understood you correctly) is to simply override the css.
In your site stylesheet or html head section you just need to override the following css selector

.ui-datepicker-current-day .ui-state-active { background: #000000; }

编辑

请牢记您的修改,以下操作应该起作用(假设您可以使日期选择器停止刷新)

With your edit in mind, the following should work (assuming you can get the datepicker to stop refreshing)

onSelect: function(value, date) {
    date.dpDiv.find('.ui-datepicker-current-day a')
        .css('background-color', '#000000');
}

这篇关于如何更改jQuery Datepicker的单元格颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆