HTMLSelectElement:The select Element

The select element is represented by the HTMLSelectElement object. It implements the properties and methods shown in the following table.

NameDescriptionReturns
autofocusthe autofocus attributeboolean
disabledthe disabled attributeboolean
formReturns the form that this element is associated withHTMLFormElement
multiplethe multiple attributeboolean
namethe name attributestring
requiredthe required attributeboolean
sizethe size attributenumber
typeReturns select-multiple if the element has the multiple attribute, and select-one otherwisestring
optionsReturns the collection of option elementsHTMLOptionElement[]
lengthGets or sets the number of option elementsnumber
[<index>] Gets the element at the specified indexHTMLElement
selectedOptionsReturns the selected option elementsHTMLOptionElement[]
selectedIndexReturns the index of the first selected option elementnumber
valueGets or sets the selected valuestring
willValidateReturns true if the element will be subject to input validation when the form is submitted; returns false otherwiseboolean
validationMessageReturns the error message that would be shown to the user if input validation was appliedstring
checkValidity()Performs input validation on the elementboolean
setCustomValidity(<msg>) Sets a custom validation messagevoid
labelsReturns the label elements associated with this elementHTMLLabelElement[]
Home 
  JavaScript Book 
    DOM