YouTip LogoYouTip

Prop Optgroup Label

HTML DOM OptionGroup label Property

HTML DOM OptionGroup label Property

-- Learning not just technology, but dreams!

JavaScript Reference

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<ol>

HTML DOM Option Object

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 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 for 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 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 the option group:

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

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

The output of x will be:

Swedish Cars

Try it yourself Β»


Related Articles

HTML Reference: HTML <optgroup> label Attribute


OptionGroup Object Reference OptionGroup Object

ByteDance Coding Plan supports Doubao, GLM, DeepSeek, Kimi, MiniMax and other mainstream large models, officially supplied, stable and reliable.

Xunfei Xingchen Coding Plan includes free model call quotas, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform. Configuration Guide Β₯3.9/ month Activate Now

Click to Share Notes

← Dom Obj ScriptProp Optgroup Disabled β†’