Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • eq() filtering in Jquery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 309
    Comment on it

    It helps in reducing the set matched of elements in a form of the index. It is a zero based indexing. By zero-based indexing we mean that the indexing begins from zero. First, an element is indexed as zero and thus simultaneously indexing goes on. So we can reduce the set of matched elements on the basis of the index and apply a specific attribute to the particular index. Thus it is a very powerful tool to apply the attribute to a particular element from a group of similar elements.

     

    <!doctype html>
    <html lang="en">
    <head>
    	<meta charset="utf-8">
    	<title>eq demo</title>
    <style>
    	ul{list-style-type: none}
    	li {
    		width: 60px;
    		height: 60px;
    		margin: 10px;
    		float: left;
    		border: 2px solid blue;
    	}
    	.green {
    		background: green;
    	}
    </style>
    	<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
    	<ul>
    		<li></li>
    		<li></li>
    		<li></li>
    		<li></li>
    		<li></li>
    		<li></li>
    	</ul>
    <script>
    	$( "body" ).find( "li" ).eq( 2 ).addClass( "green" );
    </script>
    </body>
    </html>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: