Highlight dates in specific range with jQuery's datepicker

user286928 picture user286928 · Mar 5, 2010 · Viewed 61.8k times · Source

I need to highlight the dates between a start date and an end date, which I should be able to specify. Can anyone help me?

Answer

Dave Archer picture Dave Archer · Mar 5, 2010

You can use the beforeShowDay event. It will get called for each date that needs to be shown in the calendar. It passes in a date and return an array with [0]= isSelectable, 1= cssClass, [2]=Some tooltip text

$('#whatever').datepicker({
            beforeShowDay: function(date) {
             if (date == myDate) {
              return [true, 'css-class-to-highlight', 'tooltipText'];

              }
           }
});