HTMLSelectElement:The select Element
The select element is represented by the HTMLSelectElement object. It implements the properties and methods shown in the following table.
Name | Description | Returns |
---|---|---|
autofocus | the autofocus attribute | boolean |
disabled | the disabled attribute | boolean |
form | Returns the form that this element is associated with | HTMLFormElement |
multiple | the multiple attribute | boolean |
name | the name attribute | string |
required | the required attribute | boolean |
size | the size attribute | number |
type | Returns select-multiple if the element has the multiple attribute, and select-one otherwise | string |
options | Returns the collection of option elements | HTMLOptionElement[] |
length | Gets or sets the number of option elements | number |
[<index>] | Gets the element at the specified index | HTMLElement |
selectedOptions | Returns the selected option elements | HTMLOptionElement[] |
selectedIndex | Returns the index of the first selected option element | number |
value | Gets or sets the selected value | string |
willValidate | Returns true if the element will be subject to input validation when the form is submitted; returns false otherwise | boolean |
validationMessage | Returns the error message that would be shown to the user if input validation was applied | string |
checkValidity() | Performs input validation on the element | boolean |
setCustomValidity(<msg>) | Sets a custom validation message | void |
labels | Returns the label elements associated with this element | HTMLLabelElement[] |