X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook