.add() (since jQuery 1.0) builds a new jQuery object from the union of the current matched elements and extras you pass in — selector, DOM node(s), HTML string, or another jQuery object (1.1+). It does not insert nodes into the page.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("p").add("div") // union of p + div
$("li").add("p") // list items + paragraph
$("p").add(document.getElementById("a"))
$("p").add("<b>hi</b>") // HTML in memory only
// Wrong — original unchanged:
// pdiv.add("div");
// Right:
// pdiv = pdiv.add("div");
Call
What it does
Matched set
Starting collection
Selector / element / html
Extras to merge (1.0+)
jQuery selection
Merge another set (1.1+)
selector, context
Scoped search (1.4+)
Return value
New jQuery union (must capture or chain)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select a starting set (e.g. $("div") or $("li")).
Step 2
Call .add(selector), .add(element), .add(html), or .add($other).
Step 3
Chain a method on the new set, or assign: set = set.add(…).
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 — Official: Border Divs, Then Add Paragraphs
Only early chain steps hit the original set (jQuery API demo idea).
list item 1 [red]
list item 2 [red]
list item 3 [red]
a paragraph [red]
(document order, not argument order)
How It Works
Select. Start with every li.
Add. Merge the following p.
Order. Since 1.4, same-document sets sort as they appear on the page.
Frequently Asked Questions
.add() creates a new jQuery object that is the union of the current matched elements plus extra elements you pass in — a selector, DOM element(s), HTML snippet, or another jQuery object. Available since jQuery 1.0.
No. Official docs: .add() returns a new set and leaves the original unchanged. Capture it: collection = collection.add(el); or chain directly.
.add() only builds a larger jQuery collection in memory. .append() inserts nodes into the DOM. HTML passed to .add() will not appear on the page until you use an insertion method.
Since jQuery 1.4, when all elements are in the same document, .add() sorts them in document order — not necessarily the order you passed arguments.
Use .not(selector|elements) to drop items from the combined set, or .end() to return to the selection before .add() in a chain.
Anything $() accepts: a selector (1.0), DOM element(s) (1.0), HTML string (1.0), a jQuery object (1.1), or selector plus context (1.4).