반응형
<h1 id= "title">Grab me!</h1>
이 코드를 html의 body태그에 추가한다.
js의 페이지에 다음 태그도 추가.
document.getElementById()
autofocus
js파일에
title 함수를 document.getElementById("title")
=== "html문서에서 요소 이름을 id에서 가져온다. 그리고 가져올 요소는 'title'이다"
지정해 준 뒤에
console.log(title.id); === "title의 id를 호출"
console.log(title.className) === "title의 className을 호출"
'Developer' 카테고리의 다른 글
serching for element 2 (0) | 2021.12.28 |
---|---|
Searching For Elements (0) | 2021.12.28 |
The document object (0) | 2021.12.28 |
Contiditonals part Three.. (0) | 2021.12.27 |
조건문 (conditionals) if-else (0) | 2021.12.27 |