How can I clone all the contents of a div (including memory data for input’s or other tags) and place them into another div?
I tried using the innerHTML property, but that doesn’t copy any information entered into text boxes in the meantime.
Does anyone have any solutions?
Plain javascript: use
var clone = [somediv].cloneNode(true). Be sure to change the id of the clone, if applicable!cloneNode(true)will copy all properties and child nodes of the original, afiak it will also copy the values of input fields. It will not copy handlers assigned to the original element. See also MDNI’ve edited this jsfiddle (intented to answer another SO-question) to demonstrate it.