I would like to detect when a specific HTML element on the page becomes hidden. This usually happens due to a parent element (maybe few levels up) becoming hidden. Is there a simple way to detect this. Or do I need to traverse the DOM and check each parent?
                +3 
                A: 
                
                
              
            $(foo).is(":hidden")
is supposed to be able to figure that out for you in newer jQuery versions.
                  Matti Virkkunen
                   2010-09-24 22:45:37
                
              
                +3 
                A: 
                
                
              
            You can just check if it's :hidden, for example:
$(".selector:hidden").length > 0
//or
$(".selector").is(":hidden")
This works if the parent is hidden, or any parent, or the element directly...as long as the element itself has no dimensions, it's :hidden.
                  Nick Craver
                   2010-09-24 22:45:42
                
              
                +2 
                A: 
                
                
              
            Like this:
HTML:
<div id="test">
    <div id="test1">
    test
    </div>
</div>
CSS:
#test{
    display:none;
}
JS:
alert($('#test1').is(":visible"))
                  treeface
                   2010-09-24 22:46:21
                
              
                
                A: 
                
                
              
            jQuery uses offsetHeight. That works in most browsers. But you can check that without jQuery too.
                  AutoSponge
                   2010-09-24 23:04:54