HTMLOptGroupElement: label property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{ APIRef("HTML DOM") }}

The **label** property of the {{domxref("HTMLOptGroupElement")}} interface is a string value that reflects the {{htmlelement("optgroup")}} element's [label](/en-US/docs/Web/HTML/Reference/Elements/optgroup#label) attribute, which provides a textual label to the group of options.

Value

A string.

Examples

js
const optionGroup = document.getElementById("groupB");
console.log(optionGroup.label);
optionGroup.label = `${optionGroup.label} (${optionGroup.children.length})`;

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{htmlelement("optgroup")}}
  • HTML [label](/en-US/docs/Web/HTML/Reference/Elements/optgroup#label) attribute