更改FullCalendar一天背景颜色 [英] Change the day background color in FullCalendar

查看:9375
本文介绍了更改FullCalendar一天背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using FullCalendar in my asp.net application. I need to change the day background color.

我有什么到目前为止已经试过:

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天改变天的背景颜色。

But my need is to change the background color of days, 7 days onward from current date.

示例

今天是2013 - 月 - 29。我需要改变的天以下的背景颜色。

Today is 2013-July-29. I need to change the background color of below days.

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

我怎样才能做到这一点?

How can i do this ?

推荐答案

您可以做到这一点是这样的:

You can do it like this:

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/

这篇关于更改FullCalendar一天背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆