![]() |
VOOZH | about |
The eq() method is an inbuilt method in jQuery that is used to locate the selected elements directly and returns an element with a specific index.
Syntax:
$(selector).eq(index)
Parameters: Here the parameter "index" specifies the index of the element.
Can either be positive or a negative number.
NOTE:
jQuery code to show the working of the eq() method:
Example 1: Below code will select the specified elements.
Output:
Example 2: Below code will select the specified elements with negative index.
Output:
jQuery : eq() vs get():