Latest web development tutorials

jQuery: eq () selector

jQuery selector jQuery selector

Examples

Select the second <p> element:

$("p:eq(1)")

try it"

Definition and Usage

: Eq () selector to select the element with the specified index values.

index values ​​start at 0, so the index value of the first element is 0 (not 1).

The most common usage: used in conjunction with other selectors, select the specified index specified in the combination of elements (such as the above example).


grammar

$(":eq(index)")

参数 描述
index 必需。规定元素的索引。


jQuery selector jQuery selector