Objekt možnosti HTML DOM
Možnost Objekt
Objekt Option představuje prvek HTML <option>.
Přístup k objektu Option
K prvku <option> můžete přistupovat pomocí getElementById():
Příklad
var x = document.getElementById("myOption");
Tip: K objektu Option můžete také přistupovat prohledáváním kolekce prvků formuláře nebo kolekce možností rozevíracího seznamu.
Vytvořte objekt Option
Element <option> můžete vytvořit pomocí metody document.createElement():
Příklad
var x = document.createElement("OPTION");
Vlastnosti objektu Option
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 |
Standardní vlastnosti a události
Objekt Option také podporuje standardní vlastnosti a události .
Související stránky
HTML reference: HTML tag <option>