JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<input type="text" class="datepickeryearonly" />
<br>
<input type="text" class="change-datepicker" />
JavaScript
$(".datepickeryearonly").datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yy',
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
$(".change-datepicker").on("change", function(){
var date = new Date($(this).val(), 0, 1);
$(".datepickeryearonly").datepicker('setDate', date);
})