如何使用其DOM元素创建表单的副本 [英] How to create a copy of a form with its DOM elements

查看:36
本文介绍了如何使用其DOM元素创建表单的副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建具有所有表单元素的表单副本,以便可以操纵该副本并且保持原样不变?

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?

推荐答案

像这样使用纯JavaScript cloneNode

Using plain javascript cloneNode like this


var dupNode = node.cloneNode(deep);

示例


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

这是文档.

希望有帮助.

这篇关于如何使用其DOM元素创建表单的副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆