Blog/노마드코더 - 초보자를 위한 바닐라 자바스크립트
#2-6 DOM If else Function practice
const title = document.querySelector("#title"); const BASE_COLOR = "rgb(52, 73, 94)"; const OTHER_COLOR = "#7f8c8d"; function handleClick() { const currentColor = title.style.color; if (currentColor === BASE_COLOR) { title.style.color = OTHER_COLOR; } else { title.style.colo = BASE_COLOR; } } function init() { title.style.color = BASE_COLOR; title.addEventListener("click", handleClick); } init()..
2021. 8. 29.