为什么要删3次才能全部删除掉?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<div id="content">
<h1>ht5ml</h1>
<h1>p5hp</h1>
<h1>ja5vascript</h1>
<h1>jqu5ery</h1>
<h1>jav5a</h1>
</div>
<script type="text/javascript">
function clearText() {
var content=document.getElementById("content");
// 在此完成该函数
var head=document.getElementsByTagName("h1");
alert(head.length);
for(var i=0;i<5;i++)
{
alert(i);
content.removeChild(head[i]);
}
}
</script>
<button onclick="clearText()">清除节点内容</button>
</body>
</html>