开发者

jquery datepicker displaying off a button click, is there a way to determine display state (show/hide)?

开发者 https://www.devze.com 2023-02-07 13:39 出处:网络
I\'d like to make the button into a toggle but I looked at the docs and couldn\'t find a isHidden isVisible type of property...

I'd like to make the button into a toggle but I looked at the docs and couldn't find a isHidden isVisible type of property...

.showCalendar is my button and #weekDate i开发者_Python百科s my input field. Is there a way to get the display state of datepicker?

 $('.showCalendar').click(function () {
    $('#weekDate').datepicker("show");
 });


You can check visibility of widget and toggle widget as following:

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


To my knowledge, there is no way to get the display state of the date picker (apparently, applying :visible to the UI widget does not work).

However, you can solve your problem by binding to the toggle event:

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

精彩评论

暂无评论...
验证码 换一张
取 消