HTML DOM
The label property of the HTMLOptGroupElement interface is a string value that reflects the optgroup element's label attribute, which provides a textual label to the group of options.
Value
A string.
Examples
const optionGroup = document.getElementById("groupB");
console.log(optionGroup.label);
optionGroup.label = `${optionGroup.label} (${optionGroup.children.length})`;
Specifications
Browser compatibility
See also
- optgroup
- HTML
labelattribute
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
