How does jQuery.eq() method work in jQuery?

If you want to return an element with a definite index number of the selected elements, then use the eq() method. The first element has index 0, the second element has index 1, etc. Yes, the index number starts at 0.


You can try to run the following code to learn how to work with jQuery.eq() method,

Live Demo

<!DOCTYPE html>
<script src=""></script>
    $("p").eq(3).css("background-color", "gray");

 <p>Free Learning</p>
 <p>Free Text Tutorials</p>
 <p>Free Video Tutorials</p>
 <p>Tutor Connect</p>