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
    • 127
    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 :

    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. </head>
    5. <body>
    6. <div style="border: 1px solid black;">
    7. <p>This is the first paragraph in a div.</p>
    8. <p>This is the last paragraph in a div.</p>
    9. </div><br>
    10.  
    11. <div style="border: 1px solid black;">
    12. <p>This is the first paragraph in another div.</p>
    13. <p>This is the last paragraph in another div.</p>
    14. </div>
    15.  
    16. </body>
    17. </html>

    jQuery Code :

    1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    2. <script>
    3. $(document).ready(function(){
    4. $("div p").last().css("background-color", "yellow");
    5. });
    6. </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
Reset Password
Fill out the form below and reset your password: