<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<div id="content">
<h1>html</h1>
<h1>php</h1>
<h1>javascript</h1>
<h1>jquery</h1>
<h1>java</h1>
</div>
<script type="text/javascript">
var y=new Array;
function clearText() {
var content=document.getElementById("content");
// 在此完成该函数
var x=content.childNodes;
var n=x.length-1;
var m=0,e;
while(x[n].nodeType!=1)
{
n--;
}
while(y[m]!=null)
{
m++;
}
e=content.removeChild(x[n]);
y[m]=e;
e=null;
}
function resetText()
{
var content=document.getElementById("content");
var addcontent=document.createElement("h1");
var m=y.length-1;
while(y[m]==null&&m>=0)
{
m--;
}
addcontent.innerHTML=y[m].innerHTML;
y[m]=null;
content.appendChild(addcontent);
}
</script>
<button onclick="clearText()">清除节点内容</button>
<button onclick="resetText()">返回节点内容</button>
</body>
</html>
Thank you