
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM-节点</title>
</head>
<body>
<div id="div1">
<p id="p1">第一个p</p>
<p id="p2">第二个p</p>
</div>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM-节点</title>
</head>
<body>
<div id="div1">
<p id="p1">第一个p</p>
<p id="p2">第二个p</p>
</div>
<script>
var p = document.createElement("p");
var word = document.createTextNode("新创建的p标签");
p.appendChild(word);
var div1 = document.getElementById("div1");
div1.appendChild(p);
</script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM-节点</title>
</head>
<body>
<div id="div1">
<p id="p1">第一个p</p>
<p id="p2">第二个p</p>
</div>
<script>
var p = document.createElement("p");
var word = document.createTextNode("新创建的p标签");
p.appendChild(word);
var div1 = document.getElementById("div1");
div1.appendChild(p);
var p1 = document.getElementById("p1");
div1.removeChild(p1);
</script>
</body>
</html>
