jQuery appendTo() method
Example
Insert content after each
Insert at the end of the element element:
$
(
"
button
"
)
.
click
(
function
(
)
{
$
(
"
Hello World!
"
)
.
appendTo
(
"
p
"
)
;
}
)
;
Try it »
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 prependTo() method.
Syntax
$(
content
).appendTo(
selector
)
| Parameters | Description |
|---|---|
| content | Required. Specifies the content to insert (must contain HTML tags). |
**注意:**如果 *content* 是已存在的元素,它将从当前位置被移除,并在被选元素的结尾被插入。 |
| selector | Required. Specifies which element to append the content to. |
More examples
Inserting existing elements
How to use the appendTo() method to insert existing elements at the end of each selected element.
jQuery HTML/CSS methods