繁体   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?

我正在建立一个日历,显示给定月份的不同事件。 我正在使用jQuery fullcalendar

我每个月的每一天都有特定的颜色。

为此,我使用以下代码:

dayRender: function (date, cell) {
    var cellDate = date.format('D');
    cell.css('background-color', json_backgrundColor[cellDate]);      
},

json_backgrundColor[cellDate]是一个数组,其中包含每天的特定颜色。 cellDate是一个整数(特定月份的1个结束日期(28/29/30/31))。

我的问题是上个月和下个月的日子也会受到影响。 它们正在根据特定月份的值上色。

例如:-上个月的第29天获取当前月份的第29天的背景色-下个月的第1天获取当前月份的第1天的背景色

看到这张图片:

[ 示例月份

我希望上个月/下个月的几天的背景颜色是白色。 (请参见附图中标记的日期。它们不属于特定月份,我希望它们具有白色背景色)

谁知道我该如何针对他们并做到这一点?

当前月份以外的单元格将获得fc-other-month -因此,您需要做的只是检查类,并且仅在没有该单元格的情况下对其进行操作:

dayRender: function(date, cell) {
  if(!cell.hasClass('fc-other-month')) {
    cell.css('background-color', 'blue'); // or whatever
  }
}

试试这个:.fc-other-month {背景颜色:红色; }`

尝试这个:

.fc-other-month{

背景颜色:红色; }

点击这里[ https://jsfiddle.net/Venkatachalam_Perisetla/hzq47kbg/][1]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM