HTML DOM value 属性
定义和用法
value 属性可设置或返回密码域的默认值。
出于安全考虑,一些浏览器可能阻止 JavaScript 代码读取 value 属性。
语法
- passwordObject.value=text
实例
下面的例子可获得密码域的默认值:
- <html>
- <head>
- <script type="text/javascript">
- function alertValue()
- {
- alert(
document.getElementById("password1").value
)- }
- </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>