In jQuery, the append()
method is used to insert specified content as the last child (at the end of) the selected elements in the jQuery collection.
Within an HTML document, there are multiple elements. For each element, you might want to attach new elements or objects to an older element i.e. append()
an element as the last child of an existing parent element.
First, we will look at the syntax of the append()
method and see how it works.
The append()
method has two implementations:
append()
method as a function of the $(selector)
and gives the element to be appended as the argument. The appended element can be an HTML or DOM element or a jQuery tag.Note: If you keep on clicking the button, it will keep appending the text to the already created element.
Free Resources