开发者

simple jquery class array

with the do开发者_如何转开发m,

document.getElementsByClassName("myClass")[2]

selects the 3rd element of class myClass

in jQuery,

$('.myClass')

gets class myClass but how can I get the 3rd element?!


You're looking for the :eq() selector:

 $('.myClass:eq(2)')


Instead of $('.myClass:eq(2)') you can also use $('.myClass').eq(2) or, if you want a DOM element instead of a jQuery element, $('.myClass').get(2)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜