Select the container, then pass what to insert at the end.
Select the target element(s) that should receive new content.
Call .append(content) with HTML, a node, a jQuery object, or a callback.
Content becomes the last child of each match — existing children stay.
Chain further methods on the same collection if needed.
Piece
Required?
Role
Matched set
Yes
Container(s) that receive content
content
Yes*
HTML, Element, Text, Array, or jQuery (*or callback)
Callback (1.4+)
Optional
function(index, html) → content to insert
Return
—
Same jQuery collection (chainable)
Pseudocode
Pseudocode
for each matched element el:
if content is a function:
piece = content(index, el.innerHTML) // this = el
else:
piece = content
insert piece as last child of el
// existing DOM node + one target → move (not clone)
// existing DOM node + many targets → clone for all but last
return original matched set
Reference
Cheat Sheet
Keep these facts handy while inserting content.
Topic
Detail
Syntax
.append(content [, content…])
Callback
.append(function(index, html) { … }) since 1.4
Position
Last child inside each match
Since
jQuery 1.0 (callback 1.4)
vs appendTo
Same task; container-first vs content-first
vs prepend
End vs start inside the element
Move vs clone
One target moves; many targets clone
Security
Never append untrusted HTML strings
Try it
Live Preview
Append into <p id="say">I would like to say:</p> and watch the last-child insert.
Browser demo of .append() — same idea as the examples below.
I would like to say:
Result
$("#say").append(" Hello ")
→ I would like to say: Hello
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Per element. The callback runs once for each .item.
Index. Zero-based position in the matched set.
Return. Returned string/node becomes the last child.
this. Inside the function, this is the current DOM element.
Edge Cases & Pitfalls
Check these before using .append() in production.
xss
Untrusted HTML can execute code
Script tags and event attributes in appended strings are dangerous. Prefer .text() for plain text.
move
Existing nodes move, not copy
Appending a live element to one target removes it from its old parent. Clone first if you need both places.
multi
Multiple targets clone
One source node into many containers → clones for all but the last match. Plan for that when reusing widgets.
svg
SVG is not officially supported
jQuery does not officially support SVG documents for methods like .append() — results can be unexpected.
Compatibility
Browser Support
.append() has been part of jQuery since 1.0. The callback form arrived in 1.4. It works wherever your loaded jQuery version runs.
✓ Stable · jQuery 1.0+
jQuery .append()
Supported in all browsers that run jQuery 1.0+ (callback since 1.4). Use 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
.append()Universal
Bottom line: Safe for any project that already loads jQuery. Prefer .text() or sanitized HTML when content comes from users.
Analysis
Performance Notes
Approach
Cost
Best for
One .append() with a fragment
Fewer reflows
Many nodes at once
Loop of tiny .append() calls
More DOM work
Occasional single inserts
.empty().append(…)
Clear + insert
Rebuilding a list from data
For large lists, build a string or DocumentFragment, then append once. Avoid appending inside a tight loop when hundreds of nodes are involved.
Remember
Key Takeaways
Role: insert content as the last child inside matched elements.
Twin:.appendTo() does the same job with reversed syntax.
Move: one target moves a live node; many targets clone.
Safety: never append untrusted HTML strings.
One line:.append() adds content at the end inside a container — use it for lists, logs, and dynamic UI growth.
Frequently Asked Questions
.append() inserts content as the last child of each matched element. It accepts HTML strings, DOM elements, text nodes, arrays, jQuery objects, or a callback (since 1.4). Returns the same jQuery collection for chaining. 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').
.append() inserts as the last child. .prepend() inserts as the first child. Use append for bottom-of-list adds; use prepend for newest-first feeds.
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.
Yes. Pass several HTML strings, DOM nodes, or jQuery objects: $('body').append($div1, newdiv2, existingEl). They insert in order as last children.
Since jQuery 1.4, yes. .append(function(index, html)) runs once per matched element. Return the content to insert. Inside the function, this is the current DOM element.
Do not append untrusted HTML strings — script tags and event attributes can run (XSS). Prefer .text() for plain text, or escape/sanitize HTML before inserting.