jQuery eq() Method

Last Updated:

jQuery eq() Method

The jQuery eq() method returns an element with a specific index number of the selected elements.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery eq() Method</h1> <p>This is paragraph0</p> <p>This is paragraph1</p> <p>This is paragraph2</p> <script> $(document).ready(function(){ $("p").eq(1).css("color", "red"); }); </script> </body> </html>

Syntax

$(selector).eq(index);

Parameter Values

Value Type Explanation
index Required Specifies the index of the element.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
eq()YesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author