计入什么标签form.elements
?
<html>
<head>
<title>
form process
</title>
<script>
function showelements()
{
var form = document.getElementById("f");
var n = form.elements.length;
alert(n);
}
</script>
</head>
<body>
<form id="f" action="#" method="post">
<p>Hello</p>
<input type="text" />
<input type="text" />
<button onclick="showelements()">Click</button>
</form>
</body>
</html>
我认为n = 4
因为有 4 个元素:p
, input
, input
, button
, 但结果n = 3
.