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