<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页 </title>
<script type = "text/javascript">
window.onload = function(){
var b = document.documentElement.getElementsByTagName("input");
alert(b.length);
for(int i = 0 ; i < b.length ; i++)
{
alert(b[i].type);
}
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" />
<input id="Reset1" type="reset" value="reset" />
<input id="Submit1" type="submit" value="submit" />
<input id="Text1" type="text" /> </body>
</html>我运行了没有错
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页 </title>
<script type = "text/javascript">
window.onload = function(){
var b = document.documentElement.getElementsByTagName("input");
alert(b.length);
for(int i = 0 ; i < b.length ; i++)
{
alert(b[i].type);
}
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" />
<input id="Reset1" type="reset" value="reset" />
<input id="Submit1" type="submit" value="submit" />
<input id="Text1" type="text" /> </body>
</html>我运行了没有错
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页 </title>
<script type = "text/javascript">
window.onload = function (){
var b = document.getElementsByTagName("input");
alert(b.length);
for(var i = 0 ; i < b.length ; i++) // /// 这里 没有int {
alert(b[i].type);
}
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" />
<input id="Reset1" type="reset" value="reset" />
<input id="Submit1" type="submit" value="submit" />
<input id="Text1" type="text" /> </body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页 </title>
<script type = "text/javascript"> window.onload = function(){
var b = document.documentElement.getElementsByTagName("input");
alert(b.length);
for(var i = 0 ; i < b.length ; i++)
{
alert(b[i].type); }
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" />
<input id="Reset1" type="reset" value="reset" />
<input id="Submit1" type="submit" value="submit" />
<input id="Text1" type="text" /></body>
</html>
第二条是对的,谢谢老大。
第一条VS不认document点不出来哪个函数只能用document.documentElement.getElementsByTagName("input");
不过document.getElementsByTagName("input");运行没问题