HTML DOM type 属性

定义和用法

type 属性可设置表单元素的类型。对于密码域,该属性总是 "password"。

语法

  1. passwordObject.type

实例

下面的例子返回了该密码域的表单元素类型:

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