diff options
Diffstat (limited to 'files')
-rw-r--r-- | files/ja/web/api/htmlinputelement/labels/index.html | 70 |
1 files changed, 70 insertions, 0 deletions
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 +--- +<div>{{APIRef("DOM")}}</div> +<p><code><strong>HTMLInputElement.labels</strong></code> は読み取り専用プロパティで、 {{HTMLElement("input")}} 要素に関連付けられた {{HTMLElement("label")}} 要素の {{domxref("NodeList")}} を返します。</p> + +<h2 id="Syntax">構文</h2> + +<pre class="brush: js">var <var>labelElements</var> = <var>input</var>.labels; +</pre> + +<h3 id="Return_value">返値</h3> + +<p>{{domxref("NodeList")}} で、その <code><input></code> 要素に関連付けられた <code><label></code> 要素が入ったものです。</p> + +<h2 id="Example">例</h2> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><label id="label1" for="test">Label 1</label> +<input id="test"/> +<label id="label2" for="test">Label 2</label> +</pre> + +<h3 id="JavaScript">JavaScript</h3> + +<pre class="brush: js">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" + } +});</pre> + +<p>{{EmbedLiveSample("Example", "100%", 30)}}</p> + +<h2 id="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("HTML WHATWG", "forms.html#dom-lfe-labels", "labels")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{SpecName("HTML5 W3C", "forms.html#dom-lfe-labels", "labels")}}</td> + <td>{{Spec2("HTML5 W3C")}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">ブラウザーの互換性</h2> + +<p>{{Compat("api.HTMLInputElement.labels")}}</p> |