Jquery datepicker showing button click, is there a way to determine the display state (show / hide)?

I would like to make a button in the toggle switch, but I looked at the documents and could not find the isHidden isVisible property ...

.showCalendar is my button, and #weekDate is my input field. Is there any way to get datepicker display state?

$('.showCalendar').click(function () { $('#weekDate').datepicker("show"); }); 
+4
source share
2 answers

As far as I know, there is no way to get the display state of the date picker (apparently by applying : the visible to the widget user interface does not work ).

However, you can solve your problem by attaching an event to toggle :

 $(".showCalendar").toggle(function() { $("#weekDate").datepicker("show"); }, function() { $("#weekDate").datepicker("hide"); }); 
+2
source

You can check the visibility of the widget and switch the widget as follows:

 $(".dp-icon").click(function (event) { var visible = $(".has-dp").datepicker("widget").is(":visible"); $(".has-dp").datepicker(visible ? "hide" : "show"); }) 
+5
source

Source: https://habr.com/ru/post/1337522/


All Articles