2013-04-29 75 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

文本是一個單獨的元件,因此它具有獨立的事件處理程序。如果添加的事件處理文字以及,你會得到的結果我想你正在尋找:

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

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

這是你的updated jsFiddle