Oggetto opzione HTML DOM
Oggetto Opzione
L'oggetto Option rappresenta un elemento HTML <opzione>.
Accedi a un oggetto opzione
Puoi accedere a un elemento <option> usando getElementById():
Esempio
var x = document.getElementById("myOption");
Suggerimento: puoi anche accedere a un oggetto Option eseguendo una ricerca nella raccolta di elementi di un modulo o nella raccolta di opzioni di un elenco a discesa.
Crea un oggetto opzione
Puoi creare un elemento <option> usando il metodo document.createElement():
Esempio
var x = document.createElement("OPTION");
Proprietà dell'oggetto opzione
Property | Description |
---|---|
defaultSelected | Returns the default value of the selected attribute |
disabled | Sets or returns whether an option is disabled, or not |
form | Returns a reference to the form that contains the option |
index | Sets or returns the index position of an option in a drop-down list |
label | Sets or returns the value of the label attribute of an option in a drop-down list |
selected | Sets or returns the selected state of an option |
text | Sets or returns the text of an option |
value | Sets or returns the value of an option to be sent to the server |
Proprietà ed eventi standard
L'oggetto Option supporta anche le proprietà e gli eventi standard .
Pagine correlate
Riferimento HTML: tag HTML <opzione>