Reputation: 12998
Is there a way to give a class to the first 17 days on a jquery datepicker calendar?
I have tried this but it just seems to add the class to every day...
beforeShowDay: function(date) {
for (i = 0; i < 17; i++) {
return [true, 'myClass'];
}
return [false, ''];
}
EDIT:
I've managed to nearly get it with the following code:
beforeShowDay: function (date) {
if (date <= new Date().setDate(new Date().getDate()+17) && date >= new Date() ) {
return [true, 'myClass'];
}
return [true, ''];
}
The only problem is that it doesn't give the class to todays date. Any ideas why?
Upvotes: 2
Views: 5546
Reputation: 546
maybe something like:
beforeShowDay: function(date) {
var today = new Date(), maxDate;
today.setHours(0,0,0,0);
maxDate = new Date().setDate(today.getDate() + 17);
if (date <= maxDate && date >= today ) {
return [true, 'myClass'];
}
return [true, ''];
}
Upvotes: 5