forms 返回一个集合 (一个HTMLCollection对象),包含了了当前文档中的所有form元素.
<!DOCTYPE HTML>
<html>
<head>
<title> document form test</title>
</head>
<body>
<form action="1.html" name="form1">
<input type="text" name="username" value="kear">
<input type="text" name="password" value="pass">
</form>
</body>
<script>
window.onload = function(){
var form01 = document.forms;
console.log(form01);
var form00 = document.forms[0];
console.log(form00);
console.log(form00.username.value);
alert(form00.password.value);
};
</script>
</html>
运行结果如下: