Change the text of an option element in a drop-down list:
The text property sets or returns the text of an option element.
Tip: If the value property is not specified for an option element, then the text content will be sent to the server when the container form is submitted.
The text property is supported in all major browsers.
Return the text property:
Set the text property:
Value | Description |
---|---|
text | Specifies the text of the option element |
Return Value: | A String, representing the text of the option element |
---|
Return the text of the selected option in a drop-down list:
Get the text of all options in a drop-down list: