이미지 hover시 색 변화 문제

조회수 707회

각각 색이 다른 3가지 이미지가 있고 해당 이미지에 마우스를 호버시키면 일정 값으로 바뀌었다가

마우스 리브시에 다시 원래색으로 돌아가는 코드를 짜려합니다.

var strong = "#01152c";
var strong_hover = "#001121";

var normal = "#041c3a" ;
var normal_hover = "#032549";

var weak = "#082750";
var weak_hover ="#0b345e";

$(".area").hover(function(){
    if(this.attributes.fill.value == strong) {
        this.style.fill = strong_hover;
    } else if (this.attributes.fill.value == normal) {
        this.style.fill = normal_hover;
    } else if (this.attributes.fill.value == weak) {
        this.style.fill = weak_hover;
    }
}, function(){
    if(this.attributes.fill.value == strong_hover){
        this.style.fill = strong;   
    } else if (this.attributes.fill.value == normal_hover){
        this.style.fill = normal;
    } else if (this.attributes.fill.value == weak_hover){
        this.style.fill = weak;
    }
});

이런식으로 코드를 짜봤는데 호버시에 원하는색으로까지는 바뀌는데 본래의 색으로 돌아오지 않습니다.

어떤 문제가 있을까요?

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)