This method is used to return the element with choosing index number of the selected elements.In this method, indexing is starting with 0 i.e first element have a index number 0.
Example :
HTML Code :
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>This is first line(0)</p>
<p>This is second line(1).</p>
<p>This is third line(2).</p>
<p>This is fourth line(3)</p>
</body>
</html>
jQuery Code :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").eq(2).css("background-color", "yellow");
});
</script>
Output :
This is first line(0)
This is second line(1).
This is third line(2).// in jQuery code i have choosen index 2, so this will be affected i.e color will be changed
This is fourth line(3)
0 Comment(s)