HTML DOM alt 属性

定义和用法

alt 属性设置或返回在浏览器不支持密码域时显示的替代文本。

语法

  1. passwordObject.alt=alternate_text

实例

下面的例子可返回密码域的替代文本:

  1. <html>
  2. <body>
  3.  
  4. <form>
  5. <input type="password" alt="Password field" id="pwd1" />
  6. </form>
  7.  
  8. <p>The alt text for the password field is:
  9. <script type="text/javascript">
  10. x=document.getElementById('pwd1');
  11. document.write(x.alt);
  12. </script></p>
  13.  
  14. </body>
  15. </html>