在jquery中,我们可以使用clone()
克隆一个元素及其所有事件。方法。示例:
$(".element").clone(true);
我们如何使用原生 Javascript 做同样的事情?
我正在更新我的帖子。
最佳答案
你可以这样尝试:
myelement = oldelement.cloneNode(deep)
来自MDN :
The Node.cloneNode() method returns a duplicate of the node on which this method was called.
deep Optional
true if the children of the node should also be cloned, or false to clone only the specified node.
关于javascript - 如何在没有 Jquery 的情况下克隆 HTML 元素及其事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34488595/