HTML DOM Opsie Voorwerp
Opsie Voorwerp
Die Opsie-objek verteenwoordig 'n HTML <opsie>-element.
Toegang tot 'n opsie-objek
Jy kan toegang tot 'n <option>-element kry deur getElementById():
Voorbeeld
var x = document.getElementById("myOption");
Wenk: Jy kan ook toegang tot 'n Opsie-objek kry deur deur die elementversameling van 'n vorm te soek, of die opsieversameling van 'n aftreklys.
Skep 'n opsie-objek
Jy kan 'n <option> element skep deur die document.createElement() metode te gebruik:
Voorbeeld
var x = document.createElement("OPTION");
Opsie Object Properties
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 |
Standaard eiendomme en geleenthede
Die Opsie-objek ondersteun ook die standaard eienskappe en gebeurtenisse .
Verwante bladsye
HTML verwysing: HTML <opsie> merker