jQuery insertAfter() 메서드
예시
각 <p> 요소 뒤에 <span> 요소를 삽입합니다.
$("button").click(function(){
$("<span>Hello world!</span>").insertAfter("p");
});
정의 및 사용
insertAfter() 메서드는 선택한 요소 뒤에 HTML 요소를 삽입합니다.
팁: 선택한 요소 앞에 HTML 요소를 삽입하려면 insertBefore() 메소드를 사용하십시오.
통사론
$(content).insertAfter(selector)
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (must contain HTML tags). Note: If content is an existing element, it will be moved from its current position, and inserted after the selected elements. |
selector | Required. Specifies where to insert the content |
직접 해보십시오 - 예
insertAfter() 메서드를 사용하여 선택한 각 요소 뒤에 기존 요소를 삽입하는 방법입니다.