HTML DOM 작은 개체는 HTML 요소와 연결됩니다. createElement() 및 getElementById() 메서드를 각각 사용하여 작은 요소를 만들고 액세스할 수 있습니다.
구문
다음은 −
의 구문입니다.작은 개체 만들기 -
var s= document.createElement("SMALL"); 예시
작은 개체에 대한 예를 살펴보겠습니다. -
<!DOCTYPE html>
<html>
<body>
<h1>Small object example</h1>
<p>Create a small element containing some text by clicking the below button</p>
<button onclick="CreateSmall()">CREATE</button>
<p>This is normal text</p>
<script>
function CreateSmall() {
var s = document.createElement("SMALL");
var txt = document.createTextNode("This is small text");
s.appendChild(txt);
document.body.appendChild(s);
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

CREATE 버튼 클릭 시 -
