Finding child div classes
ive tried to do some research but i can't find a specific answer for this.
I have the following HTML
<div class="collapsingHeader">
<div class="listItemWrapper">
<div class="itemWrapper">
<div class="itemImage"></div>
<div class="itemLabel"></div>
</div>
<div class="itemWrapper">
<div class="itemImage"></div>
<div class="itemLabel"></div>
</div>
</div>
</div>
<div class="collapsingHeader">
<div class="listItemWrapper">
<div class="itemWrapper">
<div class="itemImage"></div>
<div class="itemLabel"></div>
</div>
<div class="itemWrapper">
<div class="itemImage"></div>
<div class="itemLabel"></div>
</div>
</div>
</div>
Now, as you can see, I have 2 collapsingHeaders
, each with listItemWrapper
that contains 2 itemWrapper
, each containing an image and a label.
I am using javascript to press the "collapsingHeader" key to hide the .next element (which is the container listItemWrapper
below).
The problem I'm having here is that there is a little bad animation when itemImage
shrinking / hiding with the container. So I look further when the container is listItemWrapper
toggling to show / hide to additionally target the 2 child classes itemImage
and set them display:none
.
So my thinking was something like when the use clicks on the collapsingHeader
class ..
$(this).next().children('.itemImage')
and then update the css / class of each. But the above code does not work as expected and I think Im not using it correctly.
any ideas on how to target specific children (depth) in a div container?
Thank!
source to share