DOM Cloning elements


Example

An element can be cloned by invoking the cloneNode method on it. If the first parameter passed to cloneNode is true, the children of the original will also be cloned.

var original = document.getElementsByTagName("li")[0];
var clone = original.cloneNode(true);