Reputation: 4082
In one of my application I am creating a SVG path with the following code
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;
}
this will create a path in my SVG ( named "holder") . further in a button press event I need to extend its length. Since there are more than one paths in that SVG , so we cant take it points.
Please help Thanks
Upvotes: 0
Views: 652
Reputation: 10026
If you keep id unique you can use it to retrieve your shape with document.getElementById(id)
and modify the path from there.
Upvotes: 2