扩展SVG路径

时间:2012-05-14 07:45:36

标签: javascript html5 svg jquery-svg

在我的一个应用程序中,我正在创建一个包含以下代码的SVG路径

var points="M1180,401 S1180,476 1030 476 L100, 476";
createPath(points, id, name);


   function createPath(points, id, nane) {

                var shape = document.createElementNS(svgNS, "path");
                shape.setAttributeNS(null, "d", points);
                shape.setAttributeNS(null, "class", "path");
                shape.setAttributeNS(null, "id", id);
                document.getElementById("holder").appendChild(shape);
                return id;
}

这将在我的SVG中创建一个路径(名为“holder”)。在按钮按下事件中,我需要延长其长度。由于该SVG中有多个路径,因此我们无法接受它。

请帮忙 感谢

1 个答案:

答案 0 :(得分:2)

如果您保持ID唯一,您可以使用它来document.getElementById(id)检索您的形状,并从那里修改路径。

相关问题