jQuery API jQuery API 中英文对照版 - jQuery在线查询手册
eq(pos)
eq(pos)

将匹配的元素集合缩减为一个元素。这个元素在匹配元素集合中的位置变为0,而集合长度变成1。

返回值:jQuery

参数:

  • pos (Number): 要保留的元素的索引
 

示例:

$("p").eq(1)

HTML 代码:

<p>This is just a test.</p><p>So is this</p>

结果:

[ <p>So is this</p> ]

 
eq( pos )

Reduce the set of matched elements to a single element. The position of the element in the set of matched elements starts at 0 and goes to length - 1.

Return value: jQuery
Parameters:

  • pos (Number): The index of the element that you wish to limit to.
 

Example:

 $("p").eq(1)  
Before:
 <p>This is just a test.</p><p>So is this</p>  
Result:
 [ <p>So is this</p> ]