Objeto de caixa de seleção de entrada HTML DOM
Objeto de caixa de seleção de entrada
O objeto Input Checkbox representa um elemento HTML <input> com type="checkbox".
Acessar um objeto de caixa de seleção de entrada
Você pode acessar um elemento <input> com type="checkbox" usando getElementById():
Exemplo
var x = document.getElementById("myCheck");
Dica: Você também pode acessar <input type="checkbox"> pesquisando na coleção de elementos de um formulário.
Criar um objeto de caixa de seleção de entrada
Você pode criar um elemento <input> com type="checkbox" usando o método document.createElement():
Exemplo
var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");
Propriedades do objeto da caixa de seleção 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 |
Propriedades e eventos padrão
O objeto Input Checkbox também suporta as propriedades e eventos padrão .
Páginas relacionadas
Tutorial HTML: Formulários HTML
Referência HTML: tag HTML <input>
Referência HTML: atributo de tipo HTML <input>