這個代碼錯在哪里
<!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 nodeone=document.getElementsByTagName("div")[0].childNode;
for(i=0;i<nodeone.length;i++){
? ? document.write(nodeone[i].nodeValue);}
??
?
</script>
</body>
</html>
2017-01-20
<body>
<div>
??
? <p>javascript</p>
? <div>jQuery</div>
? <h5>PHP</h5>
</div>
<script type="text/javascript">
???? var nde=document.getElementsByTagName("div")[0].childNodes;
???? for(var i=0;i<nde.length;i++){
????? document.write(nde[i].nodeValue+nde[i].ndeName+nde[i].nodetype);
???? }
</script>
</body>
2016-12-10
2016-12-01
懂了懂了 。。。。。么么么大自己一下
2016-12-01
<!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 nodeone=document.getElementsByTagName("div")[0].childNodes;
for(i=0;i<nodeone.length;i++){
? ? document.write(nodeone[i].nodeValue+"</br>");
? ? document.write(nodeone[i].nodeName+"</br>");
? ? document.write(nodeone[i].nodeType+"</br>");
? ? }
??
?
</script>
</body>
</html>
我改成這樣了。。。
屏幕上顯示的是
javascript?
#text
3
null
P
1
#text
3
null
DIV
1
#text
3
null
H5
1
#text
3
正確嗎。。。。。。。。。。。。。
2016-12-01
知道了。。。childnode忘記加s了