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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 119
    Comment on it

    This method is used to return the last element of the selected elements.This filter help users to filtering the selected elements.

    Example :
    HTML Code :

    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>
    <div style="border: 1px solid black;">
      <p>This is the first paragraph in a div.</p>
      <p>This is the last paragraph in a div.</p>
    </div><br>
    
    <div style="border: 1px solid black;">
      <p>This is the first paragraph in another div.</p>
      <p>This is the last paragraph in another div.</p>
    </div>
    
    </body>
    </html>
    

    jQuery Code :

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("div p").last().css("background-color", "yellow");
    });
    </script>
    

    Output :
    This is the first paragraph in a div.
    This is the last paragraph in a div.

    This is the first paragraph in another div.
    This is the last paragraph in another div.// last method change the color of this p tag i.e last ( ) method

 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: