146
rated 0 times
[
150]
[
4]
/ answers: 1 / hits: 18110
/ 8 Years ago, sat, april 9, 2016, 12:00:00
I have a ul
in div
. And I have another ul
inside li
. I need to select only first ul
which located inside the div
. How to achieve that in jquery.
The markup.
<div class=parent>
<div class=clearfix>
<div class=another-div>
<ul class=first-ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
<li>Fifth</li>
<li>
<ul class=second-ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
<li>Fifth</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
I want to select the first-li
using only parent
class. I have tried $('.parent > ul')
but this is not working. and $('.parent ul')
but this selects both ul. I don't want to use first-ul
class or anything.
More From » jquery