<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form name="form1">
<div>
<label for="username">姓名</label>
<input id="username" value="zyz">
</div>
<div>
<label for="password">密码</label>
<input id="password" value="123">
</div>
</form>
<script>
console.log(form1) // 输出元素标签
console.log(username) // 输出元素标签
console.log(password) // 输出元素标签
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form name="form1">
<div>
<label for="username">姓名</label>
<input id="username" value="zyz">
</div>
<div>
<label >密码</label>
<input name="password" value="123">
</div>
<button id="btn">按钮</button>
</form>
<script>
console.log(document.form1.password.value) // 123 反正name是有系统提示的
console.log(document.form1.username.value) // zyz id也能获取打印出来
</script>
</body>
</html>