Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery Filtering - eq( ) method

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 121
    Comment on it

    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)

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: