<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="style.css" rel="stylesheet">
<script src="main.js" defer></script>
</head>
<body>
<p>위</p>
<p>코</p>
<p>드</p>
<button onclick="위()">위</button>
<button onclick="코()">코</button>
<button onclick="드()">드</button>
</body>
</html>
JS
function 위(){
var p = document.getElementsByTagName('p')
p[0].innerHTML = "위코드"
}
function 코(){
var p = document.getElementsByTagName('p')
p[1].innerHTML = "코드"
}
function 드(){
var p = document.getElementsByTagName('p')
p[2].innerHTML = "드드"
}