.insertAfter(target) inserts every matched element immediately after the target as a sibling (since jQuery 1.0). Same job as .after(), but content comes first.
Remember
$("<p>Test</p>").insertAfter(".inner") // create + insert
$("p").insertAfter("#foo") // move existing <p>s
$("#note").insertAfter(".box") // content first
// Same result as: $(".box").after($("#note"))
Select (or create) content, then place it after a target.
Build or select the content to insert.
Choose the target (selector, element, or jQuery object).
Call .insertAfter(target).
Chain on the returned inserted set if needed.
Piece
Required?
Role
Matched set
Yes
Content to insert (left side)
target
Yes
Selector / element / jQuery / HTML string
Callback
No
Not supported — use .after(fn) instead
Pseudocode
Pseudocode
content = matched elements (or newly created nodes)
targets = resolve(target)
for each target t:
if first target:
move content after t // not cloned
else:
clone content after t // clones for extra targets
return new set of inserted nodes
// (original + clones when multiple targets)
Reference
Cheat Sheet
Keep these facts handy while inserting siblings.
Topic
Detail
Syntax
$(content).insertAfter(target)
Since
jQuery 1.0
Position
Next sibling after target
vs after
Same result; content-first vs anchor-first
Move / clone
1 target moves; many targets clone
Return
Inserted set (not the target)
Callback
None — prepare content first
Try it
Live Preview
Insert a note after the target box, or move an existing line.
Browser demo of .insertAfter() — same idea as the examples below.
I will move
Target box
Result
Ready — pick an action and Run
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
One target moves; many targets clone. Duplicate id values on clones break uniqueness.
callback
No callback argument
Need per-target dynamic markup? Use .after(fn) instead.
xss
HTML strings can execute code
Do not build markup from URL params, cookies, or form fields without escaping.
svg
SVG is not officially supported
Using jQuery DOM insert methods on SVG may behave unexpectedly unless a method documents SVG support.
Compatibility
Browser Support
.insertAfter() has been part of jQuery since 1.0. Return-set behavior for single-target inserts was clarified in 1.9 for reliable .end() chaining.
✓ Stable · jQuery 1.0+
jQuery .insertAfter()
Supported in all browsers that run jQuery 1.0+. Prefer a current jQuery 3.x build for modern projects.
100%jQuery core method
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.insertAfter()Universal
Bottom line: Everyday sibling insert. Prefer content-first when you already hold the node to place.
Analysis
Performance Notes
Approach
Cost
Best for
One target
Cheap move
Relocating a known node
Many targets
Clone + insert
Small lists of anchors
Huge multi-target sets
Expensive
Batch or use DocumentFragment patterns
Cloning across dozens of targets multiplies work. Prefer one container update when you can.
Remember
Key Takeaways
Role: insert content as the next sibling after a target.
Syntax: content first — twin of .after().
Move/clone: one target moves; many targets clone.
Return: the inserted set, ready to chain.
One line:.insertAfter() is content-first sibling insertion after a target — same result as .after() with flipped arguments.
Frequently Asked Questions
.insertAfter(target) inserts every element in the matched set immediately after the target as a sibling. The target can be a selector, DOM element, HTML string, array, or jQuery object. Returns a jQuery collection of the inserted elements. Available since jQuery 1.0.
Same job, reversed syntax. With .after(), the anchor comes first: $('p').after('<hr>'). With .insertAfter(), the content comes first: $('<hr>').insertAfter('p').
.insertAfter() inserts as the next sibling after the target. .insertBefore() inserts as the previous sibling before the target.
.insertAfter() inserts as a sibling after the target (outside). .appendTo() inserts as the last child inside the target.
One target → the element is moved. Multiple targets → clones are created for every target after the first; the returned set is the original plus clones.
No. Unlike .after(), .insertAfter() only accepts a target. Build content first, then call .insertAfter(target).
A new set of the inserted elements (useful with .end() since jQuery 1.9), not the original unrelated collection.