I am currently trying to customize a datepicker to only show Month and Year selectors but I want to only have that CSS hidden for a specific Datepicker. I am currently trying to dictate a specific picker by ID and I do not know if what I am doing is possible or if I am just doing it wrong. Below is the input I am using as well as the Css code.
$(function() {
$('#QuarterYearPicker').datepicker({
changeMonth: false,
changeYear: true,
showButtonPanel: true,
yearRange: '1950:2013', // Optional Year Range
dateFormat: 'yy',
onClose: function(dateText, inst) {
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, 0, 1));
}
});
});
#QuarterYearPicker.ui-datepicker-calendar,
.ui-datepicker-month {
display: none;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div>Pick the Year from which you want to grab data from: <input id="QuarterYearPicker" readonly /></div>
I am only trying to get this specific Datepicker to display the drop down for year and show nothing else.