jQuery after() 메서드

❮ jQuery HTML/CSS 메소드

예시

각 <p> 요소 뒤에 내용 삽입:

$("button").click(function(){
  $("p").after("<p>Hello world!</p>");
});

정의 및 사용

after() 메서드는 선택한 요소 뒤에 지정된 내용을 삽입합니다.

팁: 선택한 요소 앞에 내용을 삽입하려면 before() 메서드를 사용하십시오.


통사론

$(selector).after(content,function(index))

Parameter Description
content Required. Specifies the content to insert (can contain HTML tags)

Possible values:

  • HTML elements
  • jQuery objects
  • DOM elements
function(index) Specifies a function that returns the content to insert
  • index - Returns the index position of the element in the set

직접 해보십시오 - 예


after() 메서드로 콘텐츠를 삽입합니다.


삽입하기 기능을 사용하여 선택한 요소 뒤에 내용을 삽입하는 방법입니다.


❮ jQuery HTML/CSS 메소드