在FullCalendar中更改日背景颜色

Bis*_*han 3 javascript asp.net jquery 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);
    }        
}
Run Code Online (Sandbox Code Playgroud)

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

但我需要改变从当前日期开始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
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点 ?

Reg*_*sen 14

你可以这样做:

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");
    }

}   
Run Code Online (Sandbox Code Playgroud)

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

  • 日期没有函数getDate(),而应该是date.date(). (3认同)