<html>
<head><title>getElementById</title>
</head>
<body>
<form name="from1" action="text.html" method="post">
<input type="text" name="username" value="Id1" id="tid"/>
<input type="button" name="ok" value="baocun"/>
</form>
</body>
<script language="JavaScript">
//输出<input type="text" name="username" value="Id1" id="tid"/>标签的value的属性
var inputElement=document.getElementById("tid");
alert(inputElement.value);
//输出<input type="text" name="username" value="Id1" id="tid"/>标签的type属性的值
alert(inputElement.type);
</script>
</html>
注:id的属性是唯一的