WON.dev
chapter07 : DOM_getElementsByTagName 본문
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
onload = function(){
var hobbies = ["영화","게임","쇼핑","수면","드라이브"];
```
//모든 <h1>태그를 가져와서 배열을 생성
var headLists = document.getElementsByTagName("h1");
for(var i=0, hob = hobbies.length; i < hob; i++){
headLists[i].innerHTML = hobbies[i];
}
}
```
</script>
</head>
<body>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
</body>
</html>
'WEB.JS > 08.DOM_JS' 카테고리의 다른 글
chapter05 : DOM삭제 (0) | 2023.05.23 |
---|---|
chapter06 : DOM_getElementById (0) | 2023.05.23 |
chapter08 : DOM_getElementsByClassName (0) | 2023.05.22 |
chapter09 : DOM_querySelector (0) | 2023.05.22 |
chapter10 : DOM_style (0) | 2023.05.22 |