YouTip LogoYouTip

Traversing Add

jQuery add() Method

jQuery add() Method

-- Learning not just technology, but dreams!

jQuery Tutorial

jQuery Tutorial jQuery Introduction jQuery Installation jQuery Syntax jQuery Selectors jQuery Events

jQuery Effects

jQuery Hide/Show jQuery Fading jQuery Sliding jQuery Animation jQuery Stop Animation jQuery Callback jQuery Chaining

jQuery HTML

jQuery Get jQuery Set jQuery Add Elements jQuery Remove Elements jQuery CSS Classes jQuery css() Method jQuery Dimensions

jQuery Traversing

jQuery Traversing jQuery Ancestors jQuery Descendants jQuery Siblings jQuery Filtering

jQuery Ajax

jQuery AJAX Introduction jQuery load() Method jQuery get()/post() Methods

jQuery Other

jQuery noConflict() Method jQuery JSONP

jQuery Examples

jQuery Examples

jQuery Reference

jQuery Selectors jQuery Event Methods jQuery Effects Methods jQuery HTML / CSS Methods jQuery Traversing Methods jQuery AJAX Methods jQuery Miscellaneous Methods jQuery Properties

jQuery Plugins

jQuery Validate jQuery Cookie jQuery Accordion jQuery Autocomplete jQuery Growl jQuery Password Validation jQuery Prettydate jQuery Tooltip jQuery Treeview

jQuery HTML / CSS Methods

jQuery AJAX Methods

jQuery add() Method

jQuery Traversing Methods jQuery Traversing Methods

Example

Add the <p> and <span> elements to an existing element set (<h1>):

$("h1").add("p").add("span")

Try it yourself Β»


Definition and Usage

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

The method adds elements to the entire document if no context parameter is specified. If a context parameter is specified, the elements are added only within the context element.


Syntax

$(selector).add(element,context)
Parameter Description
element Required. Specifies the selector expression, jQuery object, one or more elements, or an HTML fragment to add to the existing set of elements.
context Optional. Specifies the point in the document where the selector expression should start matching.

Example

More Examples

DOM

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

HTML Fragment

Use an HTML fragment to add <span> elements to existing <p> elements.


jQuery Traversing Methods jQuery Traversing Methods

jQuery HTML / CSS Methods

jQuery AJAX Methods

ByteDance Coding Plan supports mainstream large models like Doubao, GLM, DeepSeek, Kimi, MiniMax, officially supplied, stable and reliable.

Xunfei Star Coding Plan includes free model call quotas, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform. Configuration Guide Β₯3.9/month Subscribe Now

Click to Share Notes

Cancel

Write notes...

Image URL

Image description

Image size Γ—

Share notes

  • Nickname (required)
  • Email (required)
  • Reference URL

Category Navigation

← Traversing ChildrenHtml Prop β†’