X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

OptionGroup label Property

OptionGroup Object Reference 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 Reference OptionGroup Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook