jQuery add() Method
Example
Puts the
and Add elements to an existing set of elements (
):
$("h1").add("p").add("span")
Try it »
Definition and Usage
The add() method adds elements to an existing set of elements.
This method adds elements across the entire document; if a context context parameter is specified, it only adds elements within that context.
Syntax
$(
selector
).add(
element,context
)
| Parameters | Description |
|---|---|
| element | Required. Specifies a selector expression, jQuery object, one or more elements, or an HTML fragment to add to the existing set of elements. |
| context | Optional. Specifies where in the document to start matching the selector expression. |
More examples
DOM
By using a DOM element reference, add the element to the existing
set of elements.
HTML fragment
Use an HTML fragment to add the element to the existing
element.
jQuery Traversal Methods