【发布时间】:2015-10-26 08:23:16
【问题描述】:
我需要获取 <svg> 元素的 SVGPoint,但由于某种原因,它在我的场景中不起作用。
考虑下面的 HTML
<body>
<svg id="inline">
</svg>
</body>
还有 javascript
var s1 = document.getElementById('inline');
console.log('point', s1.createSVGPoint());
var s2 = document.createElement("svg");
s2.setAttribute("id", "inserted");
document.getElementsByTagName('body')[0].appendChild(s2);
console.log('point2', s2.createSVGPoint());
第一个“point”按预期获取 outputtet,但“point2”输出在 chrome 中打印错误:
Uncaught TypeError: s2.createSVGPoint is not a function
我创建了一个小型 plunker 来演示:
【问题讨论】:
标签: javascript html svg