2013-04-29 2 views
1

내가 텍스트 위에있을 때 사각형의 색이 바뀌는 이유를 알고 싶습니다. 배경색은 항상 사각형과 같습니다.Raphael JS 배경 변경

http://jsfiddle.net/yVzXF/11/

paper = new Raphael(document.getElementById('canvas_container'), 500, 250); 

rectangle2 = paper.rect(130, 75, 140,40,15); 
texte = paper.text(200, 90, "Tarification et souscription\nweb") 

rectangle2.mouseover(function(){ 
    this.animate({ 
    fill : "#aaa" 
    }); 
    }); 

rectangle2.mouseout(function(){ 
    this.animate({ 
    fill : "#F90" 
    }); 
    }); 

감사

답변

1

텍스트는 별도의 요소이므로 별도의 이벤트 핸들러를 가지고있다. 여기 updated jsFiddle

texte.mouseover(function(){ 
    rectangle2.animate({ 
     fill : "#aaa" 
    }); 
}); 

texte.mouseout(function(){ 
    rectangle2.animate({ 
     fill : "#F90" 
    }); 
}); 

: 당신은뿐만 아니라 텍스트에 대한 이벤트 처리기를 추가하는 경우, 당신은 당신이 찾고있는 내가 생각 결과를 얻을 수 있습니다