表单.元素name
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
window.onload = function () {
var oForm = document.getElementById('form1');
// var oText = document.getElementById('text1'); // ID方式
// oText.value
document.onclick = function () {
alert(oForm.username.value); // name方式:表单.元素name
}
}
</script>
</head>
<body>
<form id="form1">
<input type="text" id="text1" name="username" value="" />
</form>
</body>
</html>