HTML DOM Select Object
Select Object
The Select object represents the HTML <select> element.
Access Select Object
You can access the <select> element using getElementById():
var x = document.getElementById("mySelect");
Tip:You can also access the Select object by traversing the form's elements collection.
Create Select Object
You can create a <select> element using the document.createElement() method:
var x = document.createElement("SELECT");
Select Object Collection
Collection | Description |
---|---|
options | Return a collection of all options in the drop-down list. |
Select Object Properties
Properties | Description |
---|---|
autofocus | Set or return whether the drop-down list should automatically focus when the page is loaded. |
disabled | Set or return whether the drop-down list should be disabled. |
form | Return a reference to the form containing the drop-down list. |
length | Return the number of <option> elements in the drop-down list. |
multiple | Set or return whether multiple options can be selected from the drop-down list. |
name | Set or return the name attribute value of the drop-down list. |
selectedIndex | Set or return the index of the selected option in the drop-down list. |
size | Set or return the size attribute value of the drop-down list. |
type | Return which type of form element the drop-down list is. |
value | Set or return the value of the selected option in the drop-down list. |
Select Object Methods
Method | Description |
---|---|
add() | Add options to the drop-down list. |
checkValidity() | |
remove() | Remove options from the drop-down list. |
Standard properties and events
The Select object supports both standardsPropertiesAndEvents.