Latest web development tutorials

jQuery add () method

jQuery traversal methods jQuery traversal methods

Examples

Add the <p> and <span> element to the existing elements of the portfolio (<h1>):

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

try it"

Definition and Usage

add () method to add elements to existing elements in combination.

The method to add elements to the entire document, if the provisions of the context parameter only added to the internal context element.


grammar

$(selector).add( element,context )

参数 描述
element 必需。规定要添加到已存在的元素集合的选择器表达式、jQuery 对象、一个或多个元素、HTML 片段。
context 可选。规定选择器表达式在文档中开始进行匹配的位置。

Examples

More examples

DOM
By using the DOM element reference, add the <span> element to the existing <p> element combinations.

HTML fragment
Using HTML snippet to add <span> element to the existing <p> element.


jQuery traversal methods jQuery traversal methods