<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>复制克隆节点</title>
</head>
<body>
<ul>
<li>li1</li>
<li>li2</li>
<li>li3</li>
</ul>
<script>
const ul = document.querySelector('ul')
/*
* 复制节点 cloneNode()
* 参数为空或者 false,则是浅拷贝
* 参数为 true,则是深拷贝
*/
let clone1 = ul.children[0].cloneNode()
let clone2 = ul.children[0].cloneNode(true)
// 添加节点
ul.appendChild(clone1)
ul.appendChild(clone2)
</script>
</body>
</html>