The standard code for DatePicker is:
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<p>Date: <input type="text" id="datepicker"></p>
How to launch datepicker onclick event from inline HTML, I mean:
<input ... onclick="" >
and with no separate JS code?
I tried:
<p>Date: <input type="text" id="datepicker" onclick="$(function() {$('#datepicker').datepicker();});"></p>
But it’s working only on second click.
How to make it work on first click?
That work by any chance?
I’m no expert, but I believe you were having to click it twice because the first click merely initialised it as a datepicker. After this initialising, it’s behaving as a normal datepicker, regardless of the onclick.