I'm looking to hide a deeply nested div (with a class or ID name) within a container div with only class name. The container div is generated by an application so I cannot set an ID on it. I don't know exactly how many levels the div is generated so I cannot use a path - because that path sometimes changes depending on the page generated. It's almost that I need to use a loop or something.
Here's what I have
<div class ="container">
<div class ="level1">
<div class = "level2">
<other nested divs and html here...>
<div class = "levelN" id="idLevelN">
content to hide
<more divs and html here..../>
</div>
</other nested divs and html here...>
</div>
</div>
</div>
I want to hide the div with class = "levelN" id="idLevelN".
I tried all kinds of things but I give up. I tried to use find(), filter(), etc... Help? Thanks
You can use the
.children()
selector to filter all elements that are children of your selected element.You can also use
.parents()
to check thediv
with thecontainer
class is valid (is a parent).Like:
Here's a Fiddle