Is it possible to display jQuery UI datepicker without having to click on anything? I want the datepicker to be visible when the window loads. Or is this not possible? If not is there another plugin for this or is it best to create a new on my own?
Is it possible to display jQuery UI datepicker without having to click on anything? I want the datepicker to be visible when the window loads. Or is this not possible? If not is there another plugin for this or is it best to create a new on my own?
Share Improve this question asked Aug 29, 2011 at 15:29 halliewuudhalliewuud 2,7857 gold badges31 silver badges41 bronze badges4 Answers
Reset to default 5one thing you could do is give focus to the input so that the datepicker shows:
$('#datepicker').focus()
look here http://jsbin./agazes/edit#preview
or show it after creating it:
$('#datepicker').datepicker('show')
http://jsbin./agazes/2/edit#preview
This does not seem to be possible by passing an option. However, you can call the show
method after creating your datepicker:
$(document).ready(function() {
$("#yourElement").datepicker({
// your options...
}).datepicker("show");
});
http://jqueryui./demos/datepicker/#method-show
You could call the show method when you want it to open.
In Some jQuery versions show is not available, in that case use:
window.addEventListener('load', function () {
document.getElementById('datepicker').click();
});
jQuery(document).ready(function() {
$('#datepicker').bind('touchstart click', function(){
$(this).focus();
});
});