Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

class for jquery ui datepicker button

I have the following code for the jQuery UI datepicker:

$(function() {
        $(".date").datepicker({
            showOn: 'button',
            buttonText: "Choose Date",
            dateFormat: 'yy-mm-dd'
        });
    });

It creates a button on the side of the text box so people can click the box and select a date. Is it possible to apply a class to the button that is created so I can apply a CSS style to it?

like image 936
Doug Barrett Avatar asked Oct 14 '10 02:10

Doug Barrett


People also ask

How can change date format in jQuery ui DatePicker?

inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });

What is DatePicker in jQuery?

A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker usually connected to a text-box so user selection of date from the calendar can be transferred to the textbox.

How do I use DateRangePicker?

Add DateRangePicker to the applicationAdd the HTML input element with an ID attribute as element for DateRangePicker to your index. html file. Import the DateRangePicker component to your app. ts and append it to the #element [src/app/app.


1 Answers

You can't add an additional class through an option, but it does have a class: ui-datepicker-trigger, so if you just style directly or as a descendant of an identifiable container it'll work, for example:

.ui-datepicker-trigger { color: red; }
//or...
.myContainer .ui-datepicker-trigger { color: red; }

Or, add a different class to the button manually after creating the datepicker (which creates the button):

$(function() {
    $(".date").datepicker({
        showOn: 'button',
        buttonText: "Choose Date",
        dateFormat: 'yy-mm-dd'
    }).next(".ui-datepicker-trigger").addClass("someClass");
});
like image 145
Nick Craver Avatar answered Nov 11 '22 17:11

Nick Craver