返回值:jqueryeq(index|-index)
概述
获取第n个元素
参数
indexintegerv1.1.2
一个整数,指示元素基于0的位置,这个元素的位置是从0算起。
-indexintegerv1.4
一个整数,指示元素的位置,从集合中的最后一个元素开始倒数。(1算起)
示例
参数index描述:
获取匹配的第二个元素
html 代码:
<p> this is just a test.</p> <p> so is this</p>
jquery 代码:
$("p").eq(1)
结果:
[ <p> so is this</p> ]
参数-index描述:
获取匹配的第二个元素
html 代码:
<p> this is just a test.</p> <p> so is this</p>
jquery 代码:
$("p").eq(-2)
结果:
[ <p> this is just a test.</p> ]