From 65d95ceeaf294384181454b9cf73c70319c2e563 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sun, 11 Apr 2021 18:01:31 +0900 Subject: Web/API/HTMLInputElement/labels を新規翻訳 (#378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 2021/02/20 時点の英語版に基づき新規翻訳 --- .../ja/web/api/htmlinputelement/labels/index.html | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 files/ja/web/api/htmlinputelement/labels/index.html (limited to 'files/ja/web/api/htmlinputelement/labels') diff --git a/files/ja/web/api/htmlinputelement/labels/index.html b/files/ja/web/api/htmlinputelement/labels/index.html new file mode 100644 index 0000000000..b5a305f949 --- /dev/null +++ b/files/ja/web/api/htmlinputelement/labels/index.html @@ -0,0 +1,70 @@ +--- +title: HTMLInputElement.labels +slug: Web/API/HTMLInputElement/labels +tags: +- API +- HTML DOM +- HTMLInputElement +- Property +- Reference +translation_of: Web/API/HTMLInputElement/labels +--- +
{{APIRef("DOM")}}
+

HTMLInputElement.labels は読み取り専用プロパティで、 {{HTMLElement("input")}} 要素に関連付けられた {{HTMLElement("label")}} 要素の {{domxref("NodeList")}} を返します。

+ +

構文

+ +
var labelElements = input.labels;
+
+ +

返値

+ +

{{domxref("NodeList")}} で、その <input> 要素に関連付けられた <label> 要素が入ったものです。

+ +

+ +

HTML

+ +
<label id="label1" for="test">Label 1</label>
+<input id="test"/>
+<label id="label2" for="test">Label 2</label>
+
+ +

JavaScript

+ +
window.addEventListener("DOMContentLoaded", function() {
+  const input = document.getElementById("test");
+  for(var i = 0; i < input.labels.length; i++) {
+    console.log(input.labels[i].textContent); // "Label 1" and "Label 2"
+  }
+});
+ +

{{EmbedLiveSample("Example", "100%", 30)}}

+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName("HTML WHATWG", "forms.html#dom-lfe-labels", "labels")}}{{Spec2("HTML WHATWG")}}変更なし
{{SpecName("HTML5 W3C", "forms.html#dom-lfe-labels", "labels")}}{{Spec2("HTML5 W3C")}}初回定義
+ +

ブラウザーの互換性

+ +

{{Compat("api.HTMLInputElement.labels")}}

-- cgit v1.2.3-54-g00ecf