I want to copy an svg group but I really dont know what I missed.Here the code : For the group:
<g id="exCar" x="50" y="500" transform="" >
<path ..
<path ...
<image
<text ..
</g>
And function to copy:
function cloning(){
var newCar = document.getElementById("exCar").cloneNode(true);
document.getElementById("newCar").setAttribute("x",250);
document.getElementById("newCar").setAttribute("y",600);
document.getElementById("exCar").appendChild(newCar);
alert("!!!!");
};
Please help me to understand what is wrong..
Instead of
document.getElementById("newCar").setAttribute("x",250);
It should be:
newCar.setAttribute("x", 250)
exCar
before transforming it, so that newCar
will not carry the features. cloneNode creates a deep copy of the object, so once you clone it it will have all it's properties up to that point - mihai 2012-04-03 22:20