Hello World!").appendTo("p"); }); ```"> Hello World!").appendTo("p"); }); ```" />
Easy Tutorial
❮ Traversing Contents Event Trigger ❯

jQuery appendTo() Method

jQuery HTML/CSS Methods

Example

Insert a <span> element at the end of each <p> element:

$("button").click(function(){
    $("<span>Hello World!</span>").appendTo("p");
});

Definition and Usage

The appendTo() method inserts HTML elements at the end of the selected elements.

Tip: To insert HTML elements at the beginning of the selected elements, use the prependTo() method.


Syntax

Parameter Description
content Required. Specifies the content to insert (must include HTML tags). <br> <br> Note: If the content is an existing element, it will be removed from its current position and inserted at the end of the selected element.
selector Required. Specifies which element to append the content to.

More Examples

Insert Existing Elements


jQuery HTML/CSS Methods

❮ Traversing Contents Event Trigger ❯