Latest web development tutorials
 

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

Internet Explorer Firefox Opera Google Chrome Safari

The label property is supported in all major browsers.


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;

The result of x will be:

Swedish Cars
Try it Yourself »

Related Pages

HTML reference: HTML <optgroup> label attribute


< OptionGroup Object