Skip to content

Commit

Permalink
New page for HTMLOptGroupElement.label (#36016)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Sep 23, 2024
1 parent 9d96a61 commit 5ca22d7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions files/en-us/web/api/htmloptgroupelement/label/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "HTMLOptGroupElement: label property"
short-title: label
slug: Web/API/HTMLOptGroupElement/label
page-type: web-api-instance-property
browser-compat: api.HTMLOptGroupElement.label
---

{{ 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/Element/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/Element/optgroup#label) attribute

0 comments on commit 5ca22d7

Please sign in to comment.