开发者

Calling children of specified index?

开发者 https://www.devze.com 2023-01-16 21:40 出处:网络
Anyone know the proper syntax to write this statement? $(\'.nav ul li\')[0].children(\"a\") For some reason this is not working. The return i开发者_如何学Pythons that its not a function. :(You can

Anyone know the proper syntax to write this statement?

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

For some reason this is not working. The return i开发者_如何学Pythons that its not a function. :(


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消