HTML DOM defaultValue 属性

定义和用法

defaultValue 属性可设置或返回密码域的默认值。

注释:该默认值是在 HTML "value" 属性中规定的默认值。

语法

passwordObject.defaultValue=somevalue

实例

下面的例子可获得密码域的默认值:

<html>
<head>
<script type="text/javascript">
function alertValue()
  {
  alert(document.getElementById("password1").defaultValue)
  }
</script>
</head>
<body>

<form>
<input type="password" id="password1" value="thgrt456" />
<input type="button" id="button1" onclick="alertValue()" 
value="Show default value" />
</form>

</body>
</html>