.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.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("<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"))
Call
What it does
Matched set
Content to insert (left side)
target
Selector / element / jQuery / HTML string
Callback
Not supported — use .after(fn) instead
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Build or select the content to insert.
Step 2
Choose the target (selector, element, or jQuery object).
Step 3
Call .insertAfter(target).
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.
insertAfter. Content on the left; target on the right.
after. Target on the left; content on the right.
Pick one. Use content-first when you already hold the node.
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.