Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is jquery append() method?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 228
    Comment on it

    Hello Readers,

    append() is the jquery method and is used in jquery to Add elements to the end or after the completion of text in jquery of the selected elements.

    Syntax :

    selector.append( content )
    

    Parameter :

    content this parameter is used to insert after each target or text (HTML or Text).

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("#btn1").click(function(){
            $("p").append(" <b>Appended text</b>.");
        });
    
        $("#btn2").click(function(){
            $("ol").append("<li>Appended item</li>");
        });
    });
    </script>
    </head>
    <body>
    
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    
    <ol>
      <li>List item 1</li>
      <li>List item 2</li>
      <li>List item 3</li>
    </ol>
    
    <button id="btn1">Append text</button>
    <button id="btn2">Append list items</button>
    
    </body>
    </html>
    

    In the above code, we use the append() method to add the list item to the given ordered list.

 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: