jQuery select or hide deeply nested div within a div with a class -
i'm looking hide nested div (with class or id name) within container div class name. container div generated application cannot set id on it. don't know how many levels div generated cannot use path - because path changes depending on page generated. it's need use loop or something.
here's have
<div class ="container"> <div class ="level1"> <div class = "level2"> <other nested divs , html here...> <div class = "leveln" id="idleveln"> content hide <more divs , html here..../> </div> </other nested divs , html here...> </div> </div> </div>
i want hide div class = "leveln" id="idleveln".
i tried kinds of things give up. tried use find(), filter(), etc... help? thanks
you can use .children()
selector filter elements children of selected element.
you can use .parents()
check div
container
class valid (is parent).
like:
if ($( '#idleveln' ).parents('.container').length){ $( '#idleveln').children().hide(); }
here's fiddle
Comments
Post a Comment