在FullCalendar中更改日背景颜色

我在我的asp.net应用程序中使用FullCalendar 。 我需要改变一天的背景颜色。

到目前为止我尝试了什么:

dayRender: function (date, cell) { var today = new Date(); var end = new Date(); end.setDate(today.getDate()+7); if (date.getDate() === today.getDate()) { cell.css("background-color", "red"); } var start = new Date(); start.setDate(today.getDate()+1); while(start <= end){ //alert(start + "\n" + tomorrow); if(start.getDate() == date.getDate()){ cell.css("background-color", "yellow"); } var newDate = start.setDate(start.getDate() + 1); start = new Date(newDate); } } 

这改变了整天的背景颜色。 演示

但我需要改变从当前日期开始的7天后的天数背景颜色。

今天是2013年7月29日。 我需要更改下面几天的背景颜色。

 2013-July-30 2013-July-31 2013-August-01 2013-August-02 2013-August-03 2013-August-04 2013-August-05 

我怎样才能做到这一点 ?

你可以这样做:

 dayRender: function (date, cell) { var today = new Date(); var end = new Date(); end.setDate(today.getDate()+7); if (date.getDate() === today.getDate()) { cell.css("background-color", "red"); } if(date > today && date <= end) { cell.css("background-color", "yellow"); } } 

http://jsfiddle.net/z8Jfx/7/

 dayRender : function(date, cell) { var idx = null; var today = new Date().toDateString(); var ddate = date.toDate().toDateString(); if (ddate == today) { idx = cell.index() + 1; cell.css("background-color", "azure"); $( ".fc-time-grid .fc-bg table tbody tr td:nth-child(" + idx + ")").css( "background-color", "azure"); } }