Trip
Trip

Reputation: 27114

Calling children of specified index?

Anyone know the proper syntax to write this statement?

$('.nav ul li')[0].children("a")

For some reason this is not working. The return is that its not a function. :(

Upvotes: 0

Views: 56

Answers (1)

Yi Jiang
Yi Jiang

Reputation: 50125

You can try this for getting the first element from the results.

$('.nav ul li').first().children("a")

Or if you need a specific index

$('.nav ul li').eq(0).children("a")

You can also use the selectors :eq(n) and :first if you want.

Upvotes: 1

Related Questions