You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tag란 'anchor', 'div', 'section', 'button' 같은 것을 의미함
const title = document.getElementsByTagName("h1");
console.log(title);
querySelector & querySelectorAll 🩵🩵🩵🩵(중요)
querySelector: element를 CSS방식으로 검색할 수 있음
const title = document.querySelector(".hello h1");
console.log(title);
// querySelector에는 hello가 class name이라는 것과 그 안의 h1을 명시해줘야 함
// getElementsByCalssName("hello")에서 JavaScript는 우리가 class name을 넘겨줄 것을 알고 있음
// 아래 코드들은 동일한 결과값을 반환한다
const title = document.querySelector("#hello");
const title = document.getElementById("hello");
addEventListener
const title = document.querySelector(".hello:first-child h1");
function handleTitleClick() {
title.style.color = "blue"
}
title.addEventListener("click", handleTitleClick);
handleTitleClick();