본문 바로가기
javaScript/javaScript

hex color가 왜 안먹히는 지 모르겠음.

by for_pavane 2020. 3. 16.

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 일 경우

스크립트가 동작을 하지 않는데, 당최 그 이유를 모르겠음...

'javaScript > javaScript' 카테고리의 다른 글

'2020.03.19 if/else 구문 공부  (2) 2020.03.19
'2020.03.18  (0) 2020.03.18
강좌 변경  (0) 2020.03.18
너무 어려움  (0) 2020.03.17
javaScript 강좌  (0) 2020.03.15

댓글