JSFiddle - React, Tailwind, and code Playground
by doug65536
HTML
<input type="date">
<button>Today</button>
JavaScript
// jQuery plugin starts here
(function($) {
$.fn.setDate = function(date) {
return this.each(function() {
$(this).val([
date.getFullYear(),
("0" + (date.getMonth()+1)).substr(-2),
("0" + date.getDate()).substr(-2)
].join('-'));
});
};
}(jQuery));
// jQuery plugin ends here
$('button').on('click', function() {
var today = new Date();
$('input').setDate(today);
});