Start with the content, then name the target container.
Create or select the element(s) you want to insert.
Call .appendTo(target) with a selector, element, HTML string, array, or jQuery object.
Those elements become the last child of each resolved target.
Chain on the returned inserted set when you need the moved/cloned nodes.
Piece
Required?
Role
Matched set
Yes
Content to insert (existing or created)
target
Yes
Selector, Element, HTML string, Array, or jQuery
Return
—
Inserted set (since 1.9: original + clones when multi-target)
Pseudocode
Pseudocode
content = matched elements (or newly created markup)
targets = resolve(target) // selector / element / jQuery…
for each target t:
if last target:
move content into t as last child
else:
clone content into t as last child
return inserted set // original + clones (jQuery 1.9+)
// Twin API:
targets.append(content) ≡ content.appendTo(targets)
Reference
Cheat Sheet
Keep these facts handy while inserting into a target.
Topic
Detail
Syntax
.appendTo(target)
Position
Last child inside each target
Since
jQuery 1.0
vs append
Same task; content-first vs container-first
vs prependTo
End vs start inside the target
Move vs clone
One target moves; many targets clone
Return (1.9+)
Inserted set — friendlier with .end()
With detach
stash.appendTo("#box") reinserts safely
Try it
Live Preview
Move or create content into #box with .appendTo().
Browser demo of .appendTo() — same idea as the examples below.
Outside: FOO!
I have nothing more to say...
Result
$("span").appendTo("#box")
→ span moves into #box as last child
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Create Markup and Insert
Build an element on the fly, then drop it into a list.
#panel removed, then reinserted into #container
Events and .data() kept by detach
How It Works
Detach. Removes #panel but keeps jQuery data and handlers.
Hold.stash stores that collection for later.
Reinsert.stash.appendTo("#container") places it as the last child.
Why. Cleaner than .remove() when you need the same node again.
Edge Cases & Pitfalls
Check these before using .appendTo() in production.
xss
Untrusted HTML can execute code
Building $("<div>" + user + "</div>") is unsafe. Prefer .text() on a created element, then .appendTo().
move
Existing nodes move, not copy
One target removes the node from its old parent. Clone first if you need both places.
multi
Multiple targets clone
One source into many containers → clones for all but the last. The returned set includes those clones (jQuery 1.9+).
svg
SVG is not officially supported
jQuery does not officially support SVG documents for methods like .appendTo() — results can be unexpected.
Compatibility
Browser Support
.appendTo() has been part of jQuery since 1.0. Return-value behavior for single-target inserts was clarified in jQuery 1.9. It works wherever your loaded jQuery version runs.
✓ Stable · jQuery 1.0+
jQuery .appendTo()
Supported in all browsers that run jQuery 1.0+. Prefer a current jQuery 3.x build for modern projects (1.9+ return set recommended).
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
.appendTo()Universal
Bottom line: Safe for any project that already loads jQuery. Use content-first syntax when creating nodes; use .append() when the container is already selected.
Analysis
Performance Notes
Approach
Cost
Best for
One .appendTo() with a fragment
Fewer reflows
Many nodes at once
Loop of tiny .appendTo() calls
More DOM work
Occasional single inserts
.detach() + later .appendTo()
Cheap park/restore
Temporary hide without losing state
Build a batch of nodes, then call .appendTo() once. Avoid inserting inside a tight loop when hundreds of nodes are involved.
Remember
Key Takeaways
Role: insert matched elements as the last child of a target.
Twin:.append() does the same job with reversed syntax.
Move: one target moves a live node; many targets clone.
Detach:stash.appendTo(target) is the standard reinsert.
One line:.appendTo() is content-first insertion at the end of a target — perfect after $("<…>") or .detach().
Frequently Asked Questions
.appendTo(target) inserts every matched element as the last child of the target. 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 .append(), the container comes first: $('#list').append('<li>'). With .appendTo(), the content comes first: $('<li>').appendTo('#list').
With one target, jQuery moves the element. With multiple targets, it clones for every target except the last — the original moves to the final target. Since jQuery 1.9, appendTo returns the inserted set (original plus clones when needed).
Store detached elements with var stash = $('#panel').detach(). Reinsert later with stash.appendTo('#container'). Events and .data() survive because detach keeps jQuery state.
A CSS selector ('#foo'), a DOM element, an HTML string, an array of elements, or a jQuery object. Matched elements become the last child of each resolved target.
.appendTo() inserts as the last child of the target. .prependTo() inserts as the first child. Same content-first pattern — choose end vs start.
Do not build HTML strings from untrusted input — script tags and event attributes can run (XSS). Prefer $('<li>').text(userText).appendTo(target) for plain text.