简体   繁体   English

jQuery fullcalendar:如何定位和更改不属于当前月份的日期的背景色?

[英]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.

相关问题 如何仅以全日历方式更改选定日期的背景颜色? - How can I change background color only for selected days in fullcalendar? 如何更改Fullcalendar一个月的天数? - How can i change number of days in a month for Fullcalendar? 在FullCalendar中更改日期背景颜色 - Change the days background color in FullCalendar 如何在FullCalendar中更改今天前几天的背景颜色? - How to change background color of days before today in FullCalendar…? fullcalendar:我怎样才能获得相关查看月份的第一天和最后一天(而不是上一个\\下个月的天) - fullcalendar: how can i get the first and last day of the relevant viewed month (and not the days of of the prev \ next month) 如何使用我的代码无法运行的jquery更改滚动类的背景颜色? - How can I change the background color of a class on scroll using jquery my code isn't working? jQuery FullCalendar:更改每个星期六的颜色,该月的最后一个星期六除外 - jQuery FullCalendar : Change the color of every saturday except last saturday in the month 如何更改 FullCalendar 中所选日期的背景颜色 - How to change background color of selected date in FullCalendar 单击下个月或上个月时,将当前日期的新背景色保持为全日历 - keep the new background color of current day in fullcalendar when click on next month or previous month 如何将光标自动滚动到当前月的当前日期 - How can i auto-scroll cursor to an current date of current month in fullcalendar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM