Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  152] [ 6]  / answers: 1 / hits: 134644  / 13 Years ago, thu, january 19, 2012, 12:00:00
<div class=second>
<div class=selector id=selFirst></div>
<div class=selector id=selSecond></div>
<div></div>
</div>


How to get #selFirst using element index not the ID?



this:



var $selFirst = $(.second:nth-child(1));
console.log($selFirst);


is returning :



jQuery(div.second)

More From » jquery

 Answers
62

If you know the child element you're interested in is the first:



 $('.second').children().first();


Or to find by index:



 var index = 0
$('.second').children().eq(index);

[#87918] Wednesday, January 18, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nestorjarettg

Total Points: 451
Total Questions: 108
Total Answers: 108

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;