如何添加一个css类到Raphael对象

如何添加一个css类到Raphael对象

问题描述:

我试图创建一个网页,使用很多Raphael对象,如线,矩形,圆。我使用不同的颜色为这些对象上的每个事件,如onmouseover一种颜色,onmouseout另一个等。所以,因为我有很多造型我想知道如果我可以指定一个CSS类这些对象。我尝试在IE上使用以下代码,但我看不到样式效果。

I'm trying to create a webpage which using a lot of Raphael objects like lines, rectangles, circle. I'm using different colors for each of the event on these objects like onmouseover one color, onmouseout another etc.. So since I have a lot of styling I was wondering if I can specify a css class to these objects. I tried using the following code on IE, but I could not see the styling effect

rectObj.attr('class','mediumBold');

mediumBold是定义的css类之一。

mediumBold is one the defined css class.

我很新鲜。任何指针都会有帮助。

I'm fairly new to this. Any pointer will be helpful.

谢谢。

我这样做:

var rph = Raphael("target",100,100);

var p = rph.rect(0, 0, 12, 12, 1);

p.node.setAttribute("class","track");