Objeto de casilla de verificación de entrada HTML DOM
Objeto de casilla de verificación de entrada
El objeto Input Checkbox representa un elemento HTML <input> con type="checkbox".
Acceder a un objeto de casilla de verificación de entrada
Puede acceder a un elemento <input> con type="checkbox" usando getElementById():
Ejemplo
var x = document.getElementById("myCheck");
Sugerencia: también puede acceder a <input type="checkbox"> buscando en la colección de elementos de un formulario.
Crear un objeto de casilla de verificación de entrada
Puedes crear un elemento <input> con type="checkbox" usando el método document.createElement():
Ejemplo
var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");
Propiedades del objeto de casilla de verificación de entrada
Property | Description |
---|---|
autofocus | Sets or returns whether a checkbox should automatically get focus when the page loads |
checked | Sets or returns the checked state of a checkbox |
defaultChecked | Returns the default value of the checked attribute |
defaultValue | Sets or returns the default value of a checkbox |
disabled | Sets or returns whether a checkbox is disabled, or not |
form | Returns a reference to the form that contains the checkbox |
indeterminate | Sets or returns the indeterminate state of the checkbox |
name | Sets or returns the value of the name attribute of a checkbox |
required | Sets or returns whether the checkbox must be checked before submitting a form |
type | Returns which type of form element the checkbox is |
value | Sets or returns the value of the value attribute of a checkbox |
Propiedades y eventos estándar
El objeto Input Checkbox también es compatible con las propiedades y eventos estándar .
páginas relacionadas
Tutorial de HTML: formularios HTML
Referencia HTML: etiqueta HTML <input>
Referencia HTML: atributo de tipo HTML <entrada>