value 属性可设置文本域的默认值。
出于安全考虑,一些浏览器可能阻止 JavaScript 代码读取 value 属性。
下面的例子可获得文本域的默认值:
<html>
<head>
<script type="text/javascript">
function alertValue()
{
alert(document.getElementById("text1").value)
}
</script>
</head>
<body>
<form>
<input type="textfield" />
</form>
</body>
</html>