我的輸出不對
<!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?childN?=?document.getElementsByTagName("div")[0].childNodes;????var?x?=?1;????for?(var?i=0;i<childN.length;i++)?{????????document.write("--"+"節點"?+?x?+?"--"?+?"<br?/>");????????document.write("節點名稱:"+childN.nodeName+"<br?/>");????????document.write("節點值:"+childN.nodeValue+"<br?/>");????????document.write("節點類型:"+childN.nodeType+"<br?/>");????????document.write("<br?/>");????????x++;????}</script></body></html>
怎么我的輸出全是undefind呢?
2020-04-12
解決了,是因為輸出的時候應該要寫成childN[i]才對