JQuery DatePicker: how to add a custom class

I need to apply my own style to my datpicker, but cannot decide how to add a custom class to the datepicker. I define my date selection as follows:

            $("#From").datepicker({
                showOn: 'button',
                buttonImage: '/Content/images/icon-calendar.gif',
                buttonImageOnly: true
            }, $.datepicker.regional['en-GB']);

How to add custom class to datepicker div?

<div class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible MY_CLASS_GOES_HERE" id="ui-datepicker-div" style="position: absolute; top: 154px; left: 499px; z-index: 1; display: none;">

I know I can write:

$("#ui-datepicker-div).addClass("MY_CLASS_GOES_HERE")

.. but can I rely on datepicker always having the identifier "ui-datepicker-div" ?? Their more elegant way to do this?

Thanks in advance.

+3
source share
1 answer

Yes, you can rely on the fact that the identifier is always the same, the same date selection is shared for several instances, so this works reliably:

$("#ui-datepicker-div").addClass("MY_CLASS_GOES_HERE");
+3

Source: https://habr.com/ru/post/1780651/


All Articles