.after(content) inserts content immediately after each matched element as a sibling (since jQuery 1.0). It returns the original jQuery set for chaining.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$(target).after(content)
$(target).after("<b>Hi</b>")
$(target).after(domNode)
$(target).after($other)
// Sibling AFTER target — not inside it
// Same job as insertAfter, reversed syntax
Call
What it does
.after()
Learn jQuery .after(): insert HTML, DOM nodes, or jQuery objects as siblings after matched elements, callback form, after vs insertAfter, examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select the target(s): $("p"), $(".item"), etc.
Step 2
Call .after(content) with HTML, a node, a jQuery object, or several arguments.
Step 3
Or pass a function (1.4+) that returns content for each matched element.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Insert HTML After a Paragraph
Official style: pass an HTML string as the next sibling.
.after() inserts content immediately after each matched element as a next sibling (not inside it). It accepts HTML strings, DOM/text nodes, arrays, jQuery objects, multiple arguments, or a callback (since 1.4). Returns the original jQuery set for chaining.
.after() inserts as the next sibling; .before() inserts as the previous sibling. Neither adds children inside the matched element.
Same DOM result, reversed syntax: $(target).after(content) vs $(content).insertAfter(target) — like append vs appendTo.
.after() adds a sibling outside the element. .append() adds a child inside the element as the last child.
For a single target, an existing DOM node is moved. For multiple targets, jQuery clones for each target except the last (the original moves to the last target).
No. Like other HTML-accepting APIs, .after() can run script from untrusted strings. Never insert raw user input, URL params, or cookies without sanitizing.