案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<ul id="myList1"><li>Coffee</li><li>Tea</li></ul>
6
<ul id="myList2"><li>Water</li><li>Milk</li></ul>
7
8
<p id="demo">请点击按钮把项目从一个列表复制到另一个列表中。</p>
9
10
<button onclick="myFunction()">试一下</button>
11
12
<script>
13
function myFunction()
14
{
15
var itm=document.getElementById("myList2").lastChild;
16
var cln=itm.cloneNode(true);
17
document.getElementById("myList1").appendChild(cln);
18
}
19
</script>
20
21
<p>请尝试把 <em>deep</em> 参数设置为 false,将仅仅克隆空的 LI 元素。</p>
22
</body>
23
</html>
24