开发者

How to retrieve a element by class name by its position

开发者 https://www.devze.com 2023-01-06 02:30 出处:网络
How do you translate the following into jQuery? document.getElementsByClassName(\'x\')[5] $(\'.x\')[5] does not seem to work. i could go with a

How do you translate the following into jQuery?

document.getElementsByClassName('x')[5]

$('.x')[5] does not seem to work. i could go with a

$('.x').each(){function(i){ if(i==5) return $(this) })

but there must be an easier inline w开发者_如何学JAVAay.


You could use the :eq() selector:

$('.x:eq(5)');
0

精彩评论

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