<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function getnum(){
var mynode= getElementsByName("myt") ;
alert(mynode.length);
}
</script>
</head>
<body>
<input name="myt" type="text" value="1">
<input name="myt" type="text" value="2">
<input name="myt" type="text" value="3">
<input name="myt" type="text" value="4">
<input name="myt" type="text" value="5">
<input name="myt" type="text" value="6">
<br />
<input type="button" onclick="getnum()" value="看看有几项?" />
</body>
</html>
//var mynode= getElementsByName("myt") ;
var mynode= getElementsByTagName("input") ;
var mynode=getElementsByName('myt');
改成var mynode=document.getElementsByName('myt');
var mynode=document.getElementsByName("myt");
getElementsByName 和 getElementsByTagName 都是document方法,引用的话必须前面加上document