4

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?

4 Answers 4

5

one thing you could do is give focus to the input so that the datepicker shows:

 $('#datepicker').focus()

look here http://jsbin.com/agazes/edit#preview

or show it after creating it:

 $('#datepicker').datepicker('show')

http://jsbin.com/agazes/2/edit#preview

Sign up to request clarification or add additional context in comments.

Comments

1

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");
});

Comments

0

http://jqueryui.com/demos/datepicker/#method-show

You could call the show method when you want it to open.

Comments

0

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();
                 });
     });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.