Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery DatePicker color Sunday red

Is there a way to change the color to, say red, the Sundays in a Jquery Datepicker?

like image 876
Obay Avatar asked Jun 14 '10 12:06

Obay


2 Answers

$('#something').datepicker({
    beforeShowDay:function(date){
        if(date.toString().indexOf('Sun ')!=-1)
            return [1,'red'];else
            return [1];
    }
}

css:

.ui-datepicker td.red a{
color:#f00 !important;
}    

Not very beautiful, but works as needed.

like image 101
A.K Avatar answered Sep 27 '22 23:09

A.K


For Sundays and Saturdays you can consider using fact that jquery datepicker adds class .ui-datepicker-week-end so you can add .ui-datepicker-week-end{color:#f00;} to you css file.

If you want to handle only Sundays you must relay on fact that this will be either first or last column in a table generated by jquery datepicker (it is locale-dependent).

General advice: use firefox+firebug(or sth similiar) to inspect html code. it gives a lot of ideas how to accomplish tasks related to jquery DOM traversing.

like image 35
dzida Avatar answered Sep 28 '22 00:09

dzida