gpt4 book ai didi

javascript - 如何使用 DOM 元素创建表单的副本

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:27 25 4
gpt4 key购买 nike

如何创建包含所有表单元素的表单副本,以便可以对副本进行操作,同时保持原始表单不变?

最佳答案

像这样使用普通的 javascript cloneNode

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

这是 documentation .

希望对您有所帮助。

关于javascript - 如何使用 DOM 元素创建表单的副本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18196541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com