📜  HTML | DOM 输入密码对象

📅  最后修改于: 2021-11-07 07:50:59             🧑  作者: Mango

HTML DOM 中的Input Password Object用于表示 type=”password”的 HTML 输入元素。
可以使用getElementById() 方法访问 type=”password”的输入元素。

句法:

  • 用于访问 input type=”password”
    document.getElementById("id");
  • 它用于创建 type=”password” 元素。
    document.createElement("input");

对象属性:

Property Description
type This property is used to return which type of form element the password field is.
value This property is used to set or return the value of the value attribute of a password field.
autocomplete This property is used to set or return the value of the autocomplete attribute of a password field.
autofocus This property is used to set or return whether a password field should automatically get focus when the page loads.
defaultValue This property is used to set or return the default value of a password field.
disabled This property is used to set or return whether a password field is disabled or not.
form This property is used to return reference to the form that contains the password field.
maxLength This property is used to set or return the value of the maxlength attribute of a password field.
name This property is used to set or return the value of the name attribute of a password field.
placeholder This property is used to set or return the value of the placeholder attribute of a password field.
readOnly This property is used to set or return whether the password field is read-only or not.
required This property is used to set or return whether the password field must be filled out before submitting a form.
size This property is used to set or return the value of the value attribute of the password field.

输入数字对象方法:

  • select():用于选择密码字段的内容。

示例 1:



  

  
    

               GeeksForGeeks           

       

DOM Input Password Object

Password:             

Click the button to get the password        of the password field.

               

             

输出:

点击按钮前:

点击按钮后:

示例 2:



  

  
    

               GeeksForGeeks           

       

DOM Input Password Object

       

Click the button to create a       Password Field.

                     

输出:

点击按钮前:

点击按钮后:

支持的浏览器:

  • 谷歌浏览器
  • 火狐浏览器
  • 边缘
  • 苹果浏览器
  • 歌剧