Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM OptionGroup label Property

OptionGroup label Property

OptionGroup Object Reference OptionGroup Object

Example

Change the label/description of the option group:

document.getElementById("myOptgroup").label="A Random Car Selection";

Try it »


Definition and Usage

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

The label attribute specifies the label/description of the option group.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the label property.


Syntax

Return the label property:

optiongroupObject

.label

Set the label property:

optiongroupObject

.label=

text

Attribute values

Value Description
text Specifies the label/description of the option group.

Technical Details

Return Value: A string representing the label of the option group.

More examples

Example

Return the label/description of the option group:

var x = document.getElementById("myOptgroup").label;

document.getElementById("demo").innerHTML=x;

x The output is:

Swedish Cars

Try it »


Related Articles

HTML Reference Manual:HTML label property


OptionGroup Object Reference OptionGroup Object