Check if datepicker is open

前端 未结 6 621
遥遥无期
遥遥无期 2021-01-01 13:19

I have a field with a datepicker. I want know if it is open. I\'ve tried with:

$(\"#filter_date\").datepicker( \"widget\" ).is(\":visible\")
<
6条回答
  •  长发绾君心
    2021-01-01 13:40

    Access the datepicker's style attribute and compare it with a style when datepicker is hidden (display: none):

    var datePickerStyle = $('.datepicker').attr('style');
    var noneStyle = 'display: none;';
    if(datePickerStyle.indexOf(noneStyle) != -1){
         console.log('shown');
    } else {
         console.log('not shown');
    }
    

提交回复
热议问题