본문 바로가기
JavaScript

[jQuery] replaceWith 사용법

by palbokdev 2021. 5. 6.

기존 요소를 제거(remove) 하고, 새로운 요소를 추가(append) 한다면 replaceWith를 이용하여 코드를 줄일 수 있다.

 

$( "div.second" ).replaceWith( "<h2>New heading</h2>" );

 

ref : api.jquery.com/replacewith/