getElementById("content")获取的是<div>的id,能不能换成getElementstagName("div")获取<div>?有点搞不清
<div id="content">
<h1>html</h1>
<h1>php</h1>
<h1>javascript</h1>
<h1>jquery</h1>
<h1>java</h1>
</div>
<script type="text/javascript">
function clearText() {
var content=document.getElementById("content");
for(var i=content.childNodes.length-1;i>=0;i--){
content.removeChild(content.childNodes[i]);
}
}
</script>
<button onclick="clearText()">清除节点内容</button>