如何更改 jquery datepicker 的单元格颜色
我有一个 jquery datepicker,我需要能够更改所选单元格日期的背景颜色.我正在尝试类似的东西:
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());
}
});
希望日期参数引用所选单元格,但似乎不起作用.
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 head 部分中,您只需要覆盖以下 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');
}