cloneNode(a) method accepts a Boolean parameter indicating whether to copy it deeply
true: means to perform deep copy and copy this node and the entire child node tree.
false: shallow copy. Only copy the node itself.
The node copy returned after copy belongs to the document, but does not have a parent node. Unless it is used to add it to the document using appendChild, insertChild(), replaceChild()
The code copy is as follows:
<div id="guoDiv">
<span>1</span>
<span>2</span>
<span>3</span>
</div>
var oDiv = document.getElementById("guoDiv");
var deepList = oDiv.cloneNode(true); //Copy child nodes
alert(deepList.childNodes.length); //3 or 7 (compatibility problem, so the result is different)
var showList = oDiv.cloneNode(false); // Only copy the reference of the current element
alert(showList.childNodes.length); //0