
더보기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div></div>
<script>
// 생성
const h1Tag = document.createElement('h1')
h1Tag.textContent = '제목'
console.log(h1Tag)
// 추가
const divTag = document.querySelector('div')
divTag.appendChild(h1Tag)
console.log(divTag)
// 삭제
divTag.removeChild(h1Tag)
</script>
</body>
</html>
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
'WEB > JavaScript' 카테고리의 다른 글
| [JavaScript][syntax] 변수 (0) | 2024.04.17 |
|---|---|
| [JavaScript][DOM 조작] 5. style 조작 (0) | 2024.04.16 |
| [JavaScript][DOM 조작] 3. HTML 콘텐츠 조작 (0) | 2024.04.16 |
| [JavaScript][DOM 조작] 2. 속성 조작 (일반 속성) (0) | 2024.04.16 |
| [JavaScript][DOM 조작] 1. 속성 조작 (클래스 속성) (0) | 2024.04.16 |





