Oggetto casella di controllo input HTML DOM
Inserisci oggetto casella di controllo
L'oggetto Input Checkbox rappresenta un elemento HTML <input> con type="checkbox".
Accedi a un oggetto Casella di controllo di input
Puoi accedere a un elemento <input> con type="checkbox" usando getElementById():
Esempio
var x = document.getElementById("myCheck");
Suggerimento: puoi anche accedere a <input type="checkbox"> cercando nella raccolta di elementi di un modulo.
Crea un oggetto Casella di controllo di input
Puoi creare un elemento <input> con type="checkbox" usando il metodo document.createElement():
Esempio
var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");
Casella di controllo Input Proprietà dell'oggetto
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 |
Proprietà ed eventi standard
L'oggetto Input Checkbox supporta anche le proprietà e gli eventi standard .
Pagine correlate
Esercitazione HTML: moduli HTML
Riferimento HTML: tag HTML <input>
Riferimento HTML: attributo tipo HTML <input>