x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
<script>
7
function getElements() {
8
var x = document.getElementsByName("x");
9
alert(x.length);
10
}
11
</script>
12
</head>
13
<body>
14
15
猫:
16
<input name="x" type="radio" value="猫"> 狗:
17
<input name="x" type="radio" value="狗">
18
<input type="button" onclick="getElements()" value="多少名称为 'x'的元素?">
19
20
</body>
21
</html>