sangrila B sangrila B - 1 month ago 34
jQuery Question

jQuery Datepicker - do not highlight today

I'm using jQuery Datepicker (jQuery 1.11.3 / jQuery UI 1.11.4 > I'm bound to these versions and can not alter or change them in any way).

Out of the box, jQuery Datepicker highlights today the following way:

<td class="ui-datepicker-days-cell-over ui-datepicker-current-day ui-datepicker-today"> <a class="ui-state-default ui-state-highlight ui-state-active" href="#" tabindex="144">26</a> </td>


Now I want to get rid of the ui-state-highlight class in order to prevent this behaviour.

I searched for numerous hints on the web, all of which are more or less the same like this (including timeouts, .find() etc.):

beforeShow:
function (textbox, instance) {
setTimeout(
function () {
$(
"#ui-datepicker-div td.ui-datepicker-today a.ui-state-highlight").removeClass('ui-state-highlight');
}, 300
);
//settimeout function end
}


However all of these solutions are not working.

Has anyone a working solution to this problem?

Kld Kld
Answer

To make sure the jquery-ui doesn't add the class after showing the datepicker you can run this code after rendering the datepicker.

$('#ui-datepicker-div').datepicker({
   //options
})
.find('a.ui-state-highlight')
.removeClass('ui-state-highlight');