Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically change the selected month in JQuery datepicker

I have a jQuery datepicker and I cannot figure out how to programmatically change the month back to the current month. After making a POST request to save the user's dates I need to return the calendar back to the current month. The calendar may be on a different month from the user playing around with different dates. I have tried setting the mindate again but that did not work.

This is not a popup calendar.

like image 516
Johnston Avatar asked Oct 21 '25 14:10

Johnston


1 Answers

Setting the datepicker back to today

$('#myDatePicker').datepicker('setDate', new Date());

setting just the month back

var date = $('#myDatePicker').datepicker('getDate');

date.setMonth( (new Date()).getMonth() );

$('#myDatePicker').datepicker('setDate', date);

FIDDLE

like image 109
adeneo Avatar answered Oct 23 '25 02:10

adeneo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!