Change the day background color in FullCalendar

后端 未结 2 821
走了就别回头了
走了就别回头了 2020-12-06 21:39

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

What i have tried so far :

         


        
相关标签:
2条回答
  • 2020-12-06 22:19

    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/

    0 讨论(0)
  • 2020-12-06 22:21
    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");
    
                                }
    
                            }
    
    0 讨论(0)
提交回复
热议问题