Change the label value of an option in a drop-down list:
The label property sets or returns the value of the label attribute in an option in a drop-down list.
The label attribute specifies a shorter version of an option.
The shorter version will be displayed in the drop-down list.
The label property is supported in all major browsers.
Return the label property:
Set the label property:
Value | Description |
---|---|
text | Specifies a shorter version for the option |
Return Value: | A String, representing the label of the option in the drop-down list. If the label attribute is not specified, it will return the <option> element's text content instead (same as the text property) |
---|
Return the label value of an option in a drop-down list:
The result of x will be:
Alert the label value of the selected option in a drop-down list:
HTML reference: HTML <option> label attribute