append() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:append


The append() method inserts specified content at the end of the selected elements.


content Required. HTML elements/jQuery objects/ DOM elements to insert
function(index,html) Optional. a function that returns the content to insert
  • index - Returns the index position of the element in the set
  • html - Returns the current HTML of the selected element

The following code shows how to Insert content at the end of all <p> elements:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<script src=""></script>
        $("p").append(" <b>Appended text</b>.");
    });//from w w  w.  j a va 2  s  .c  o m

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button id="btn1">Append text</button>


Related Tutorials