Set value of datepicker?
You need to use the setDate
function of the datepicker
library. Try this:
$('#datepicker').datepicker('setDate', new Date()); // = set to today
As this is the first post that pops up when you search for how to set date in a datepicker, here's an answer for everyone that comes here trying to figure out how to do it with vanilla JS:
const date = document.getElementById('datepicker');
date.value = new Date().toISOString().split('T')[0].slice(0, 10);
<input id="datepicker" name="date" class="mydatepicker" />