HTML DOM name 属性

定义和用法

name 属性可设置或返回密码域的名称。

语法

  1. passwordObject.name=name

实例

下面的例子可获得密码域的名称:

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