<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DOM</title>
<!--Document Object Modeling
tree 구조로 메모리에 올라간 html문서를 조작할 때 사용한다.
-->
<script type="text/javascript">
window.onload = function() {
//1. 노드 생성(태그, 내용)
var h1 = document.createElement('h1');
var text = document.createTextNode('Hello Dom!!');
//2. 노드 연결....기존 태그에 연결
h1.appendChild(text);
document.body.appendChild(h1);
};
</script>
</head>
<body>
</body>
</html>
'컴퓨터 프로그래밍 > javascript' 카테고리의 다른 글
form tag-Value, focus() (0) | 2020.05.30 |
---|---|
submit, on submit-javascript (0) | 2020.05.30 |
onclick: javascript (0) | 2020.05.30 |
for-javascript (0) | 2020.05.30 |
lotto-자바스크립트를 이용한 로또 생성기-setInterval(), clearInterval(), Math.random(), includes() (0) | 2020.05.30 |