Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JQuery - eq( index ) Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 337
    Comment on it

    JQuery have DOM filter methods which we can use to filter out elements from a list of DOM elements.

    It provides DOM traversal methods to help us select elements in a document randomly as well as in sequential method.

    DOM Traversal Methods instead of modifing the jQuery object, it filters out elements from a document.

    eq( index ) Method is one of the useful method used to reduce the set of matched elements to a single element.

    eq( index ) Method Syntax:- selector.eq( index )

    See the example given below

    HTML CODE

    <html>
    
       <head>
          <title>The jQuery Example</title>
          <script type = "text/javascript" 
             src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
           </script>
    
          <script type = "text/javascript" language = "javascript">
             $(document).ready(function() {
                $("li").eq(2).addClass("selected");
             });
          </script>
    
          <style>
             .selected { color:green; font-size:15px;}
          </style>
       </head>
    
       <body>
    
          <div>
          <h4>Mobile</h4>
             <ul>
                <li>Apple</li>
                <li>Sony</li>
                <li>HTC</li>
                <li>Samsung</li>
                <li>LG</li>
                <li>Motorola</li>
             </ul>
          </div>
    
       </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: