[英]jQuery fullcalendar: How can I target and change the background color of the days that don't belong to the current month?
I'm building a calendar that shows different events for a given month. 我正在建立一个日历,显示给定月份的不同事件。 I am using jQuery fullcalendar .
我正在使用jQuery fullcalendar 。
I have a specific color for every day of the month. 我每个月的每一天都有特定的颜色。
For that, I'm using the following code: 为此,我使用以下代码:
dayRender: function (date, cell) {
var cellDate = date.format('D');
cell.css('background-color', json_backgrundColor[cellDate]);
},
json_backgrundColor[cellDate]
is an array that contains the specific color for each day. json_backgrundColor[cellDate]
是一个数组,其中包含每天的特定颜色。 cellDate
is an integer (1-end of the specific month (28/29/30/31)). cellDate
是一个整数(特定月份的1个结束日期(28/29/30/31))。
My problem is that the days of the previous month and the next month are also affected by it. 我的问题是上个月和下个月的日子也会受到影响。 They are getting colored according to the values of the specific month.
它们正在根据特定月份的值上色。
eg: - Day 29 of the previous month is getting the background color of the day 29 of the current month - Day 1 of the next month is getting the background color of the day 1 of the current month 例如:-上个月的第29天获取当前月份的第29天的背景色-下个月的第1天获取当前月份的第1天的背景色
See this picture: 看到这张图片:
[ [
I want the background color of days from previous/next month will be white. 我希望上个月/下个月的几天的背景颜色是白色。 (see the marked days in the picture attachted. they don't belong to the specific month and I want them to be with white background color)
(请参见附图中标记的日期。它们不属于特定月份,我希望它们具有白色背景色)
Anybody knows how can I target them and do it? 谁知道我该如何针对他们并做到这一点?
The cells that fall outside of the current month get the class fc-other-month
- so all you need to do should be to check the class, and only work on the cell if it doesn't have it: 当前月份以外的单元格将获得
fc-other-month
-因此,您需要做的只是检查类,并且仅在没有该单元格的情况下对其进行操作:
dayRender: function(date, cell) {
if(!cell.hasClass('fc-other-month')) {
cell.css('background-color', 'blue'); // or whatever
}
}
Try This: .fc-other-month{ background-color: red; 试试这个:.fc-other-month {背景颜色:红色; }`
}`
Try this: 尝试这个:
.fc-other-month{
background-color: red; 背景颜色:红色; }
}
Click here[ https://jsfiddle.net/Venkatachalam_Perisetla/hzq47kbg/][1] 点击这里[ https://jsfiddle.net/Venkatachalam_Perisetla/hzq47kbg/][1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.