From ed4edb19c89e81e9f6e68f6820b166d106519be6 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Thu, 28 Oct 2021 02:00:01 +0900 Subject: Web/API/HTMLSelectElement 以下の文書を更新 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 2021/10/27 時点の英語版に同期 - add, checkValidity, disabled, form, labels, namedItem, remove, selectedIndex, selectedOptions, setCustomValidaty, type については新規翻訳 --- files/ja/web/api/htmlselectelement/item/index.md | 109 +++++++++-------------- 1 file changed, 44 insertions(+), 65 deletions(-) (limited to 'files/ja/web/api/htmlselectelement/item/index.md') diff --git a/files/ja/web/api/htmlselectelement/item/index.md b/files/ja/web/api/htmlselectelement/item/index.md index 0513a73fe7..f081c5efa2 100644 --- a/files/ja/web/api/htmlselectelement/item/index.md +++ b/files/ja/web/api/htmlselectelement/item/index.md @@ -2,84 +2,63 @@ title: HTMLSelectElement.item() slug: Web/API/HTMLSelectElement/item tags: -- API -- HTML DOM -- HTMLSelectElement -- Method -- Reference + - API + - HTML DOM + - HTMLSelectElement + - メソッド + - リファレンス +browser-compat: api.HTMLSelectElement.item translation_of: Web/API/HTMLSelectElement/item --- -
{{ APIRef("HTML DOM") }}
+{{ APIRef("HTML DOM") }} -

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

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

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

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

構文

+## 構文 -
var item = collection.item(index);
-var item = collection[index];
-
+```js +var item = collection.item(index); +var item = collection[index]; +``` -

引数

+### 引数 - +- `index` は `unsigned long` の値です。 -

返値

+### 返値 - +- `item` は {{domxref("HTMLOptionElement")}} です。 -

+## 例 -

HTML

+### HTML -
<form>
-  <select id="myFormControl">
-    <option id="o1">Opt 1</option>
-    <option id="o2">Opt 2</option>
-  </select>
-</form>
-
+```html +
+ +
+``` -

JavaScript

+### JavaScript -
// Returns the HTMLOptionElement representing #o2
+```css
+// 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")}}

- -

関連情報

- - +``` + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- 実装先の {{domxref("HTMLSelectElement")}} -- cgit v1.2.3-54-g00ecf