HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The Option object represents an HTML <option> element
The Option object represents an HTML <option> element.
Access an Option Object
You can access an <option> element by using getElementById():
var x = document.getElementById("myOption");
Create an Option Object
You can create an <option> element by using the document.createElement() method:
var x = document.createElement("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 |
The Option object also supports the standard properties and events.
HTML reference: HTML <option> tag