Change the days background color in FullCalendar

风流意气都作罢 提交于 2019-12-11 08:28:49

问题


I'm using FullCalendar in my asp.net application. There are four asp:Buttons in my application as below.

Weekends
Weekdays
Month
Year

When user click on Weekends button, i need to change the background color of Weekend days of current month.

When user click on Weekdays button, i need to change the background color of Weekdays of current month.

When user click on Month button, i need to change the background color of all days of current month.

When user click on Year button, i need to change the background color of all days of current year.

What i have tried so far :

Here is the Demo for change background color for weekends. this change background color of weekends including other months which are currently display on calendar. but i need to change only current months weekends background color only.

How can i achieve this ?


回答1:


You are almost there in your demo. You just need to filter out the days that are in other months - and luckily FullCalendar marks those days with the CSS class fc-other-month.

By changing your code slightly here's how you could do it for weekends:

$('#weekends').click(function() {

    $('.fc-day.fc-sat').not('.fc-other-month').css('backgroundColor','#bce8f1');
    $('.fc-day.fc-sun').not('.fc-other-month').css('backgroundColor','#bce8f1');

});

And an updated demo on jsfiddle: http://jsfiddle.net/z8Jfx/22/



来源:https://stackoverflow.com/questions/17942632/change-the-days-background-color-in-fullcalendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!