Javascript 可以设置id,但可以';不要将类设置为svg

Javascript 可以设置id,但可以';不要将类设置为svg,javascript,Javascript,我已经创建了一个svg动态,但无法将类名设置为该svg var circle = document.createElementNS( 'http://www.w3.org/2000/svg', 'circle'); circle.setAttribute("cx", 6); circle.setAttribute("cy", 6); circle.setAttribute("r", 4); circle.setAttribute( 'id', 'special'); (this method i

我已经创建了一个svg动态,但无法将类名设置为该svg

var circle = document.createElementNS( 'http://www.w3.org/2000/svg', 'circle');
circle.setAttribute("cx", 6);
circle.setAttribute("cy", 6);
circle.setAttribute("r", 4);
circle.setAttribute( 'id', 'special'); (this method is working), but

circle.className("abc"); **is not working** 

为什么?

嗯。。。因为这不是设置类名的方式

circle.className = "abc";

您必须以这种方式使用:

circle.className = "abc";
没有具有此名称(className)的方法,但它是元素的属性:在这种情况下,必须使用=符号:)

问候,, 凯文