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 ?
解决方案
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/