jQuery clone() 메서드

❮ jQuery HTML/CSS 메소드

예시

모든 <p> 요소를 복제하고 <body> 요소의 끝에 삽입합니다.

$("button").click(function(){
  $("p").clone().appendTo("body");
});

정의 및 사용

clone() 메서드는 자식 노드, 텍스트 및 속성을 포함하여 선택한 요소의 복사본을 만듭니다.


통사론

$(selector).clone(true|false)

Parameter Description
true Specifies that event handlers also should be copied
false Default. Specifies that event handlers should not be copied

직접 해보십시오 - 예


clone() 메서드를 사용하여 이벤트 핸들러를 포함한 요소를 복사하는 방법.


❮ jQuery HTML/CSS 메소드