Alert the value of the selected option in a drop-down list:
The value property sets or returns the value of the option (the value to be sent to the server when the form is submitted).
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 value property is supported in all major browsers.
Return the value property:
Set the value property:
Value | Description |
---|---|
value | The value to be sent to the server |
Return Value: | A String, representing the value of the value attribute of the option element |
---|
Change the value of a specific option element:
HTML reference: HTML <option> value attribute