How to create a copy of a form with its DOM elements

dom, javascript

Solution

Using plain javascript `cloneNode` like this

var dupNode = node.cloneNode(deep);

Example

var p = document.getElementById("para1"),
var p_prime = p.cloneNode(deep); 
//If "deep" is set to true it will clone all the child nodes too,
//If set to false then only the node and not the children

Here is the documentation.

Hope that helps.

Problem

How does one create a copy of a form with all of its form elements so that the copy can be manipulated and the original is left unchanged?

Original source

Related problems