-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
46 lines (31 loc) · 1021 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: "HTMLOutputElement: labels プロパティ"
short-title: labels
slug: Web/API/HTMLOutputElement/labels
---
{{APIRef("DOM")}}
**`HTMLOutputElement.labels`** は読み取り専用プロパティで、この {{HTMLElement("output")}} 要素に関連付けられた {{HTMLElement("label")}} 要素の {{domxref("NodeList")}} を返します。
## 値
この `<output>` 要素に関連付けられた `<label>` 要素の {{domxref("NodeList")}} を返します。
## 例
### HTML
```html
<label id="label1" for="test">ラベル 1</label>
<output id="test">Output</output>
<label id="label2" for="test">ラベル 2</label>
```
### JavaScript
```js
window.addEventListener("DOMContentLoaded", () => {
const output = document.getElementById("test");
for (const label of output.labels) {
console.log(label.textContent); // "ラベル 1" and "ラベル 2"
}
});
```
### 結果
{{EmbedLiveSample("Examples", "100%", 30)}}
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}