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