Reputation: 402
I have the code below to get a date from a user and then put it in a variable but how do I add an event that once the user picks a date to then add it on the screen.
<div class="container" >
<div>
<h1>Welcome to this site</h1>
<p>Please select a date below.</p>
<p>Click Here: <input type="text" name="date" id="datepicker" /><p>
</div>
<div id='test'>
</div>
<script>
$("#datepicker").datepicker();
$("#datepicker").bind("change", function () {
$("#test").text($(this).val());
});
</script>
The code works this way.
Upvotes: 0
Views: 51
Reputation: 3039
Try this:
$("#datepicker").bind("change", function () {
$("#test").text($(this).val());
});
Upvotes: 1
Reputation: 1631
try on onChange event :
var dateSelected ;
$("#datepicker").bind("change",function(){
//.. your code
dateSelected = document.getElementById('datepicker').value;
});
Upvotes: 0