<body>
<ul>
<li>javascript</li>
<li>HTML/CSS</li>
<li>jQuery</li>
</ul>
<script type="text/javascript">
var List=document.getElementsByTagName("li");
for(var i in List){
document.write("List: "+i+" |");
document.write(List[i].nodeName+":"+List[i].nodeValue+":"+List[i].nodeType+"<br/>");
}
</script>
</body>
原来该输出:
List: 0 |LI:null:1
List: 1 |LI:null:1
List: 2 |LI:null:1
上面会比var i in List多输出下面的:
List: length |undefined:undefined:undefined
List: item |undefined:undefined:undefined
List: namedItem |undefined:undefined:undefined
业余奶茶品鉴师
Yexiaomo
相关分类