我这样写不能输出节点属性,哪里错了啊
求帮助!!!!
求帮助!!!!
2016-10-19
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>节点属性</title> </head> <body> <ul> <li>javascript</li> <li>HTML/CSS</li> <li>jQuery</li> </ul> <script type="text/javascript"> var a=document.getElementsByTagName("li") for(var i=0;i<a.length;i++){ document.write(a[i].nodeName+" "+a[i].nodeValue+" "+a[i].nodeType+" "); } </script> </body> </html>
for循环那里i需要定义下。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>节点属性</title>
</head>
<body>
<ul>
<li>javascript</li>
<li>HTML/CSS</li>
<li>jQuery</li>
</ul>
<script type="text/javascript">
var a=getElementsByTagName("li")
for(i=0;i<a.length;i++)
{
document.write(a[i].nodeValue+" "+a[i].nodeType+" "+a[i].nodeName+"<br/>")
}
</script>
</body>
</html>
举报