jQuery add() 메서드
예시
기존 요소 그룹(<h1>)에 <p> 및 <span> 요소를 추가합니다.
$("h1").add("p").add("span")
정의 및 사용
add() 메서드는 기존 요소 그룹에 요소를 추가합니다.
이 메서드는 전체 문서에 요소를 추가하거나 컨텍스트 매개변수가 지정된 경우 컨텍스트 요소 내부에 요소를 추가 합니다 .
통사론
$(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 |
직접 해보십시오 - 예
요소에 대한 참조를 사용하여 기존 <p> 요소 그룹에 <span> 요소를 추가합니다.
을 사용하여 기존 <p> 요소에 <span> 요소를 추가합니다.