jquery eq () selector syntax

jquery eq () selector syntax

Action: : EQ () selector selecting elements with the specified index value. index value starting from 0, index values of all of the first element is 0 (not 1). Is often used with other elements / selector together, select the specified number of elements of a particular group (as in the example above).

Syntax: $ ( ": EQ (index)"

Parameters: index Required. Prescribed index value of the element.   Wuxi marble measurement platform 

jquery eq () Example selector

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript"> 
 
$(document).ready(function(){
    $("p:eq(1)").css("background-color","#B2E0FF");
});
</script>	
</head>
<body>
<html>
<body>
<h1>Welcome to My Homepage</h1>
<p class="intro">My name is Donald</p>
<p>I live in Duckburg</p>
<p>My best friend is Mickey</p>
<div id="choose">
Who is your favourite:
<ul>
<li>Goofy</li>
<li>Mickey</li>
<li>Pluto</li>
</ul>
</div>
</body>
</html>
</body>
</html>

Guess you like

Origin www.cnblogs.com/furuihua/p/11941161.html