Jquery - How to check, if child in hidden DIV is visible?

前端 未结 6 791
南方客
南方客 2020-12-17 21:06

how can i check a div in a hidden div ... if visible or not?

HTML

6条回答
  •  被撕碎了的回忆
    2020-12-17 21:26

    You could check the display property of the css:

    if ($("#two_child").css("display") != "none") {
        //...
    }
    

    As Gaby points out in the comments, this would not work if your elements are being hidden using visibility, so you may want to extend it to:

    var $child = $("#two_child");
    if ($child.css("display") != "none" && $child.css("visibility") != "hidden") {
        //...
    }
    

提交回复
热议问题