提示:使用(firstChild lastChild childNodes)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cpp
</title>
<script language="javascript">
function test()
{
var c=document.getElementById("h1")
alert(c.firstChild.nodeValue); //方法一 利用firstchild 输出明天休息
alert(c.childNodes[0].nodeValue); //方法二利用childNodes表示父元素下的所有的子元素(数组)
}
</script>
<body>
<center>
<h1 id="h1" onclick="test()">明天休息</h1>
</center>
</body>
</html>