How can I copy an element with Javascript?


(Stephen Voisey) #1

Hi lovely Hype folks,

Question is pretty simple. I have an element (square) with inner SVG code. How can I use Javascript to copy this element?

Many thanks,

Stephen


#2

Look at the cloneNode() method.


(Mark Hunte) #3

As @DBear suggests cloning is what you want. There are example on the site. search for clone
There are some caveats in doing a clone which are mentioned in some of the threads. i.e You cannot clone the animation of a element and you must remove the HYPE_element class names from the cloned elements


(Stephen Voisey) #4

Many thanks guys :wink: Will dig into it today.