Home >>jQuery Tutorial >jQuery :eq() Selector
jQuery :eq() selector in jQuery is used to selects an element with a specific index number which starts at 0.
Syntax:$(":eq(index)")
Parameter | Description |
---|---|
index | It is a Required parameter and used to specifies the index of the element |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p:eq(1)").css("background-color","orange");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<p class="intro">My name is phptpoint.</p>
<p>I live in Noida.</p>
<p>Who is your favourite:</p>
<ul id="fav">
<li>JAVA</li>
<li>jQuery</li>
<li>Javascript</li>
</ul>
</body>
</html>
My name is phptpoint.
I live in Noida.
Who is your favourite: