I am trying to follow the below code to implement addition of days to datepicker
[https://jsfiddle.net/up82wt76/][1]
Below is the code I implemented in Visual Studio 2022
It is a straight copy. Why it does not work?
Any help would be greatly appreciated.
$('.pickupDate').datepicker();
$('.dropoffDate').datepicker();
$('.pickupDate').change(function() {
var date2 = $('.pickupDate').datepicker('getDate', '+1d');
//date2.setDate(date2.getDate()+1);
$('.dropoffDate').datepicker('setDate', date2.getDate() + 1);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<div>
<br />
<br />
<input type="text" class="pickupDate" />
<input type="text" class="dropoffDate" />
</div>
$( document ).ready(function() {...});
or load the dependencies before executing your code.