<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="content-Type" content="text/html; charset=utf-8"/>
<head>
<title>替换节点</title>
<script type="text/javascript">
function changeNode() {
var bjNode = document.getElementById("bj");
//cloneNode代表克隆节点,参数true代表子节点也克隆
var gameNode = document.getElementById("game").cloneNode(true);
//替换
bjNode.parentNode.replaceChild(gameNode,bjNode);
}
</script>
</head>
<body>
<ul>
<li id="bj" onclick="changeNode()">北京</li>
<li>湖南</li>
<li>山东</li>
</ul>
<ul>
<li id="game">天安门<p>南锣鼓巷</p></li>
<li>快乐大本营</li>
<li>泰山</li>
</ul>
</body>
</html>