Element 식별자 API
엘리먼트를 제어하기 위한 식별자 API
Element.tagName
<!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></title>
</head>
<body>
<ul>
<li>banana</li>
<li id="active">apple</li>
<li>orange</li>
</ul>
<script>
var apple = document.getElementById('active');
// id가 active인 요소의 태그명을 출력
console.log(apple.tagName); // 'LI'
</script>
</body>
</html>Element.id
Element.className
Element.classList
Last updated