jQuery - Traversing the dom and selecting
I'm having a hard time selecting all of the first div elements inside a
parent div which appears multiple times.
For Example I need to select the first div inside every parent div that
have a class of "nav". See below to understand:
<div class="container">
<div class="nav">
<div class="sub-item"></div> **SELECT THIS**
<div class="sub-item"></div>
</div>
</div>
<div class="container">
<div class="nav">
<div class="sub-item"></div> **SELECT THIS**
<div class="sub-item"></div>
</div>
</div>
I tried this code but it only selects the div in the first parent div.
$('.nav > div').eq(0);
Any help is appreciated!
No comments:
Post a Comment