Reputation: 198
I am trying to make datepicker using jQuery and jQueryUI
My date picker fires up only after designated event occures second time.
Code is:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="jquery-ui-1.10.4.css" />
<script src="jquery-1.11.1.js"></script>
<script src="jquery-ui-1.10.4.js"></script>
<script>
$(document).ready(function(){
$( "#id1" ).click(function() {
$("#id1").datepicker();
});
});
</script>
</head>
<body>
<form>
<input type="text" id="id1" />
</form>
</body>
</html>
Here when I click on input box second time then datepicker appears but not on first click.
Can someone tell me why ?
Upvotes: 1
Views: 888
Reputation: 51072
The datepicker()
function isn't meant to be run on a click event. That's the function that sets up that input box to trigger a datepicker -- it has it's own event handling. Just run datepicker()
at document ready, and don't worry about a click handler.
Upvotes: 4