如何创建一个包含所有表单元素的表单副本,以便可以操作副本并保持原始文件不变?
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.
Use the jQuery clone object as such:
var cloned_object = $( ".hello" ).clone().
and to add it to the dom
cloned_object.appendTo( ".goodbye" );
Here is the reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.