FREE Web Template Download
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULARJS TUTORIALS REFERENCES EXAMPLES Blog
 

jQuery add() Method

jQuery HTML Methods jQuery Traversing Methods

Example

Add <p> and <span> elements to an existing group of elements (<h1>):

$("h1").add("p").add("span")
Try it Yourself »

Definition and Usage

The add() method adds elements to an existing group of elements.

This method adds elements on the whole document, or just inside context elements if the context parameter is specified.


Syntax

$(selector).add(element,context)

Parameter Description
element Required. Specifies a selector expression, a jQuery object, one or more elements or an HTML snippet to be added to an existing group of elements
context  Optional. Specifies the point in the document at which the selector expression should begin matching

Examples

Try it Yourself - Examples

DOM
Add a <span> element to an existing group of <p> elements, by using a reference to a DOM element.

HTML snippet
Using an HTML snippet to add a <span> element to an existing <p> element.


jQuery HTML Methods jQuery Traversing Methods