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?
inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });
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.
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.
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");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With