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

前端 未结 6 779
南方客
南方客 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:23

    I've saved these two selector extensions which is essentially the same as Steve's version:

    From another SO answer:

    // jQuery selector to find if an element is hidden by its parent
    jQuery.expr[':'].hiddenByParent = function(a) {
     return $(a).is(':hidden') && $(a).css('display') != 'none' && $(a).css('visibility') == 'visible';
    };
    

    From Remy Sharp & Paul Irish:

    // reallyvisible - by remy sharp & paul irish
    // :visible doesn't take in to account the parent's visiblity - 'reallyvisible' does...daft name, but does the job.
    // not neccessary in 1.3.2+
    $.expr[ ":" ].reallyvisible = function(a){ return !(jQuery(a).is(':hidden') || jQuery(a).parents(':hidden').length); };
    

提交回复
热议问题