JavaScript cloneNode():克隆節點
語法:
nodeObject.cloneNode(boolean)
參數說明:
舉例,對id="demo" 的節點進行複製:
<div id="demo"> <div>点击这里进行克隆</div> <div>节点</div> <div>节点</div> </div> <script type="text/javascript"> document.getElementById("demo").onclick=function(){ alert(this.cloneNode(true).children.length); } </script>