From ae99688e9bd75d9c870620cb4bff6bf4f1685b4f Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Mon, 26 Apr 2021 01:35:37 +0900 Subject: HTMLSelectElement.item() を新規翻訳 (#464) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2021/02/20 時点の英語版に基づき新規翻訳 --- files/ja/web/api/htmlselectelement/item/index.html | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 files/ja/web/api/htmlselectelement/item/index.html (limited to 'files/ja') diff --git a/files/ja/web/api/htmlselectelement/item/index.html b/files/ja/web/api/htmlselectelement/item/index.html new file mode 100644 index 0000000000..a716eecdb0 --- /dev/null +++ b/files/ja/web/api/htmlselectelement/item/index.html @@ -0,0 +1,90 @@ +--- +title: HTMLSelectElement.item() +slug: Web/API/HTMLSelectElement/item +tags: +- API +- HTML DOM +- HTMLSelectElement +- Method +- Reference +translation_of: Web/API/HTMLSelectElement/item +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLSelectElement.item() メソッドは、選択肢のリスト内で引数で渡された位置にある {{domxref("HTMLOptionElement")}} に対応する {{domxref("Element")}} を返します。存在しない場合は null を返します。

+ +

JavaScript では、ブラケット構文に unsigned long の値を入れた selectElt[index] の形が、 selectElt.namedItem(index) と同等です。

+ +

構文

+ +
var item = collection.item(index);
+var item = collection[index];
+
+ +

引数

+ + + +

返値

+ + + +

+ +

HTML

+ +
<form>
+  <select id="myFormControl">
+    <option id="o1">Opt 1</option>
+    <option id="o2">Opt 2</option>
+  </select>
+</form>
+
+ +

JavaScript

+ +
// Returns the HTMLOptionElement representing #o2
+elem1 = document.forms[0]['myFormControl'][1];
+
+ +

仕様書

+ + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', "#dom-select-item", "HTMLSelectElement.item()")}}{{Spec2('HTML WHATWG')}}最新のスナップショット、 {{SpecName('HTML5 W3C')}} から変更なし。
{{SpecName('HTML5 W3C', "forms.html#dom-select-item", + "HTMLSelectElement.item()")}}{{Spec2('HTML5 W3C')}}初回定義、 {{SpecName('HTML WHATWG')}} のスナップショット。
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.HTMLSelectElement.item")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf