我的代码案例
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<div>javascript<p>javascript</p><div>jQuery</div><h5>PHP</h5></div>
<script type="text/javascript">
var x=document.getElementsByTagName("div")[0].childNodes;
document.write("div子节点数的个数"+x.length+"<br/>");
document.write("-----------------------"+"<br/>");
for(i=0;i<x.length;i++){
var name=x[i].nodeName;
var value=x[i].nodeValue;;
var type=x[i].nodeType;
document.write("节点的名称"+name+"<br/>");
document.write("节点的值"+value+"<br/>");
document.write("节点的类型"+type+"<br/>");
document.write("-----------------------"+"<br/>");
}
</script>
</body>
</html>