基于this代码动画,我试图动画动态生成的SVG元素:与SVG动态添加元素
var svgnode = document.createElementNS('http://www.w3.org/2000/svg','svg');
var circle = document.createElementNS('http://www.w3.org/2000/svg','circle');
circle.setAttribute("cx", "10");
circle.setAttribute("cy", "10");
circle.setAttribute("r", "10");
circle.setAttribute("fill", "blue");
var ani = document.createElementNS("http://www.w3.org/2000/svg","animateTransform");
ani.setAttribute("attributeName", "transform");
ani.setAttribute("attributeType", "xml");
ani.setAttribute("type", "translate");
ani.setAttribute("from", "10");
ani.setAttribute("to", "100");
ani.setAttribute("begin", "0s");
ani.setAttribute("dur", "2s");
ani.setAttribute("fill", "freeze");
circle.appendChild(ani);
svgnode.appendChild(circle);
document.getElementById('mydiv').appendChild(svgnode);
的SVG显示了罚款,但动画不起作用。如果我用普通的HTML/SVG编写等效代码,它就可以工作。我正在使用Chrome。
这是工作,Chrome会V15 http://jsfiddle.net/SF5nE/ – Bakudan
升级,而它的工作 - 谢谢! – Hendekagon