jQuery eq() Method

jQuery eq() method can be used to select an element by specifying its index position. The index position of the group element like a table starts at 0. It can be negative or a position to specify.

jQuery eq() Method

Syntax

The syntax of this method is given below:-

Syntax
$(selector).eq(index)

Description of the Parameters

The description of these parameters is given below.

Parameter Name Description
selector Specify the element to select for the specified index position. You can use the element tag name, class name, or id to select. It is a required field.
index You have to specify the index position of the element to select.

jQuery eq() Method Return Specified Index Element

If you want to select the item of the group element, you have to specify the index position as given below. The method can be helpful to locate the exact element you want to select.

Example

Test it Live

Output

  • First list element
  • Second list element
  • Third element
  • Forth element


When you click the button given above, it selects the element for which you have specified the index position. After you click the button, the output shows that you have selected the second element.

You may also like to read

I hope you like this tutorial on jQuery eq() method. If you have any queries regarding the tutorial, please comment below.

References