개발/Script

[jQuery] html() 사용방법

jooon 2022. 7. 29. 15:35

jQuery에서 html() 함수가 있는데 이것의 사용용도는 html 태그를 이용하여 동적으로 구현할 수 있는 용도로 사용된다.  예를 들어보자

html 문
<div id=“test_group”></div>

js 문
var content = “”

content += “<span style=‘color:blue’>하이</span>”;

content += “<span style=‘color:red’>바이</span>”;

$(“#test_group”).html(content);

결과

하이바이

반응형