jQuery after() method
Example
Insert content after each
element:
$
(
"
button
"
)
.
click
(
function
(
)
{
$
(
"
p
"
)
.
after
(
"
Hello world!
"
)
;
}
)
;
Try it »
Definition and Usage
The after() method inserts the specified content after the selected elements.
**Tip:** To insert content before the selected elements, use before() method.
Syntax
$(
selector
).after(
content
,function(
index
))
| Parameters | Description |
|---|---|
| content | Required. Specifies the content to insert (may contain HTML tags).
Possible values: |
- index - Returns the index position of the element in the set.
More examples
after() - creating content with HTML, jQuery, and DOM
Inserting content with the after() method.
Inserting content using a function
How to use a function to insert content after the selected elements.
jQuery HTML/CSS methods