THE WORLD'S LARGEST WEB DEVELOPER SITE

OptionGroup label Property

❮ OptionGroup Object

Example

Change the label/description of an option-group:

document.getElementById("myOptgroup").label = "A Random Car Selection";
Try it Yourself »

Definition and Usage

The label property sets or returns the value of the label attribute of an option-group.

The label attribute specifies a label/description for an option-group.


Browser Support

Property
label Yes Yes Yes Yes Yes

Syntax

Return the label property:

optiongroupObject.label

Set the label property:

optiongroupObject.label = text

Property Values

Value Description
text Specifies a label/description for the option-group


Technical Details

Return Value: A String, representing the label of the option-group

More Examples

Example

Return the label/description of an option-group:

var x = document.getElementById("myOptgroup").label;
Try it Yourself »

Related Pages

HTML reference: HTML <optgroup> label attribute


❮ OptionGroup Object