Latest web development tutorials

HTML DOM OptionGroup label attribute

OptionGroup Object Reference OptionGroup objects

Examples

Change the label option group / description:

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

try it"

Definition and Usage

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

label attribute specifies the label option group / description.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the label property.


grammar

Back label properties:

optiongroupObject .label

Set label properties:

optiongroupObject .label= text

Property Value

描述
text 规定选项组的标签/描述。

technical details

return value: String representing the label option group.


More examples

Examples

Back Tab Options Group / Description:

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 <optgroup> label attribute


OptionGroup Object Reference OptionGroup objects