0
我有'SVG'元素的问题,我正在尝试使用attr()方法向'svg'圆元素添加类,但它是不工作。SVG元素上没有添加addClass()和Attr()的类
**Here is the some piece of code: **
r = new ScaleRaphael('lg-map', config.mapWidth, config.mapHeight),
attributes = {
fill: '#d9d9d9',
cursor: 'crosshair',
stroke: config.strokeColor,
'stroke-width': 1,
'stroke-linejoin': 'round',
'font-family': 'Verdana',
'font-size': '19px',
'font-weight': 'bold'
},
var pinattrs = {
'cursor': 'pointer',
'fill':pins[i].color,
'stroke':config.strokeColor,
'id': pinId,
'class':'smallCircle'
};
var pin = r.circle(pins[i].xPos, pins[i].yPos, config.pinSize).attr(pinattrs);
,其结果是:
<circle cx="425" cy="425" r="10" fill="#737373" stroke="#f2f2f2" id="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer;"></circle>
我也试过addClass()方法,但有同样的结果。
感谢
你能提供更多的代码上下文?什么是'r.circle'? –
addClass绝对不适用于SVG元素。 attr()应该但是,r.circle从哪里来? –
http://stackoverflow.com/questions/8638621/jquery-svg-why-cant-i-addclass – Khaleel