Reputation: 5545
I want to add a custom color to the disabled future dates in jQuery datepicker.
But when I try to add a custom class, the class is never added to the disabled dates.
Here is my code anyways:
<input type="text" id="picker"/>
$(function(){
$("#picker").datepicker({
maxDate: 0,
beforeShow: function(input, inst){
$('.ui-datepicker-calendar > tbody > tr > td:has(span)').each(function (index) {
console.log($(this).closest("td"));
$(this).closest("td").addClass("red");
});
}
});
});
Upvotes: 0
Views: 219
Reputation: 18600
You need to change your css for disabled date.
.ui-datepicker-calendar td.ui-state-disabled span{
color: red;
}
Upvotes: 0
Reputation: 15501
Add this CSS to your code:
td.ui-datepicker-unselectable.ui-state-disabled span{
background: red;
}
No need for beforeShow
if you are using this CSS.
Upvotes: 3