0

I want my datepicker is visible unless I call a close function. I couldnt find any function neither prevent close when I select a date, nor close it by myself manually. any ideas?

1
  • jqueryui.com/datepicker/#inline this might be the best solution...call on div to display inline then manage the visibility of the div if you want to hide it
    – abigperson
    Commented Feb 8, 2017 at 14:01

1 Answer 1

5

The solution is to show the datepicker inline. This means you attach it to a div instead of a textbox. It will always be displayed.

<div id="datepicker"></div>

$("#datepicker").datepicker();

To "close" it, simply hide the div:

$("#datepicker").hide();

See this demo for more detail: https://jqueryui.com/datepicker/#inline

Alternatively, if you leave your datepicker as it is now (not inline), you can use the "hide" method of datepicker plugin to close it manually. This was easy to find in the documentation at http://api.jqueryui.com/datepicker/#method-hide:

$("#datepicker").datepicker("hide");

Pass the string "show" instead to call the show method, which will display it again.

1
  • 1
    oh thank you for the answer. Sorry for late reply. I was so stressed to do this so I gave a break. I tried the solution that in your answer and it worked. Commented Feb 9, 2017 at 1:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.