jQuery add()Methods
Examples
Add <p> and <span> elements to an existing set of elements (<h1>):
$("h1").add("p").add("span")
Try it Yourself »
Definition and Usage
The add() method adds elements to an existing set of elements.
This method adds elements to the entire document. Ifcontexta parameter is specified, they are added only within the context element.
Syntax
$(selector).add(element,context)
| Parameters | Description |
|---|---|
| element | Required. Specifies a selector expression, jQuery object, one or more elements, or HTML fragment to be added to an existing set of elements. |
| context | Optional. Specifies where in the document the selector expression begins to match. |
More Examples
DOM
Add <span> elements to an existing set of <p> elements by using DOM element references.
HTML Fragment
Use HTML fragments to add <span> elements to existing <p> elements.
Other Extensions
jQuery
Traversing Methods