<输入密码对象
例
更改密码字段的默认值:
document.getElementById("myPsw").defaultValue = "hello";
试一试»
定义和用法
默认值属性设置或返回密码字段的默认值。
Note:默认值是在HTML中指定的值值属性。
将默认值之间的差异值属性,是默认值包含密码字段的默认/初始密码,而价值是密码字段的当前密码的一些已经作了修改之后。 如果没有变化,默认值和值是相同的(see "More Examples" below) 。
当你想找出是否密码字段的内容已被更改默认值属性是非常有用的。
浏览器支持





默认值属性在所有主流浏览器的支持。
句法
返回默认值属性:
passwordObject .defaultValue
设置默认值属性:
passwordObject .defaultValue= 属性值
技术细节
更多示例
例
返回密码字段的默认值:
var x = document.getElementById("myPsw").defaultValue;
试一试» 例
表示将默认值和value属性之间的差别的例子:
var x = document.getElementById("myPsw");
var defaultVal =
x.defaultValue;
var currentVal = x.value;
试一试»
<输入密码对象