This article describes the DOM node depth cloning function clonenode () usage. Share to everyone for your reference.
The implementation methods are as follows:
Copy Code code as follows:
<script type= "Text/javascript" >
function T () {
var Nodeul = document.getelementsbytagname (' ul ') [0];//get the UL node that needs to be replicated
var Newul = Nodeul.clonenode (true);//true represents deep copying, that is, the Li and the text along the edge; if False, copy only UL
var node_copy = document.getElementById (' Copyul ');
Node_copy.appendchild (Newul);
}
</script>
<body>
<div id= "Container" >
<ul>
<li> Spring </li>
<li> Summer </li>
<li> Autumn </li>
<li> Winter </li>
</ul>
</div>
<div id= "Copyul" >
</div>
<button onclick= "t ()" value= "" > Specify Location Add node </button>
</body>
I hope this article will help you with your JavaScript programming.