javaScript/javaScript
hex color가 왜 안먹히는 지 모르겠음.
for_pavane
2020. 3. 16. 12:08
const title = document.querySelector("#title");
const BASE_COLOR = "rgb(26, 188, 156)";
const OTHER_COLOR = "rgb(192, 57, 43)";
function handleClick(){
const currentColor = title.style.color;
console.log(currentColor);
if (currentColor === BASE_COLOR){
title.style.color = OTHER_COLOR;
}
else {
title.style.color = BASE_COLOR;
}
}
function init(){
title.style.color = BASE_COLOR;
title.addEventListener("click", handleClick);
}
init();
=====================================
위 스크립트 중 BASE_COLOR 나, OTHER_COLOR가 HEX COLOR CODE 일 경우
스크립트가 동작을 하지 않는데, 당최 그 이유를 모르겠음...