OptionGroup labelProperty

OptionGroup 对象参考手册OptionGroup Object

Example

Change the label/description of the 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 the label/description of an 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

Property 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;

xThe output result is:

Swedish Cars

Try it Yourself »


Related Articles

HTML Reference Manual:HTML <optgroup> label Attribute


OptionGroup 对象参考手册OptionGroup Object

Other Extensions