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 については新規翻訳 --- .../web/api/htmlselectelement/autofocus/index.md | 80 +++++++++------------- 1 file changed, 31 insertions(+), 49 deletions(-) (limited to 'files/ja/web/api/htmlselectelement/autofocus') diff --git a/files/ja/web/api/htmlselectelement/autofocus/index.md b/files/ja/web/api/htmlselectelement/autofocus/index.md index e3374e8fc3..79fdfd1146 100644 --- a/files/ja/web/api/htmlselectelement/autofocus/index.md +++ b/files/ja/web/api/htmlselectelement/autofocus/index.md @@ -2,69 +2,51 @@ title: HTMLSelectElement.autofocus slug: Web/API/HTMLSelectElement/autofocus tags: -- API -- HTML forms -- HTMLSelectElement -- Property -- Reference + - API + - HTML フォーム + - HTMLSelectElement + - プロパティ + - リファレンス +browser-compat: api.HTMLSelectElement.autofocus translation_of: Web/API/HTMLSelectElement/autofocus --- -

{{ APIRef("HTML DOM") }}

+{{ APIRef("HTML DOM") }} -

HTMLSelectElement.autofocus プロパティは、 HTML の {{htmlattrxref("autofocus", "select")}} 属性を反映した true または false の値を持ちます。これはユーザーが上書きしない限り、ページが読み込まれた際に関連付けられた {{HTMLElement("select")}} 要素がページ読み込み時に入力フォーカスを得るかどうかを示します。

+**`HTMLSelectElement.autofocus`** プロパティは、 HTML の {{htmlattrxref("autofocus", "select")}} 属性を反映した `true` または `false` の値を持ちます。これはユーザーが上書きしない限り、ページが読み込まれた際に関連付けられた {{HTMLElement("select")}} 要素がページ読み込み時に入力フォーカスを得るかどうかを示します。 -

この属性を指定することができるのは、 1 つの文書内のフォーム関連要素 1 つだけです。もし複数あった場合、属性が設定された最初の要素 (通常は該当する要素のうちページで最初のもの) が初期のフォーカスを得ます。

+この属性を指定することができるのは、1 つの文書内のフォーム関連要素 1 つだけです。もし複数あった場合、属性が設定された最初の要素 (通常は該当する要素のうちページで最初のもの) が初期のフォーカスを得ます。 -
-

このプロパティを設定しても、関連付けられた {{HTMLElement("select")}} 要素へフォーカスは設定されません。単純に文書へ 要素が挿入された ときにブラウザーへフォーカスを移動するよう指示するだけです。挿入後に設定した場合、すなわち文書が読み込まれた後のほとんどの場合では、目に見える効果はありません。

-
+> **Note:** このプロパティを設定しても、関連付けられた {{HTMLElement("select")}} 要素へフォーカスは設定されません。単純に文書へ*要素が挿入された*ときにブラウザーへフォーカスを移動するよう指示するだけです。挿入後に設定した場合、すなわち文書が読み込まれた後のほとんどの場合では、目に見える効果はありません。 -

構文

+## 構文 -
aBool = aSelectElement.autofocus; // Get the value of autofocus
-aSelectElement.autofocus = aBool; // Set the value of autofocus
-
+```js +aBool = aSelectElement.autofocus; // autofocus の値を取得 +aSelectElement.autofocus = aBool; // autofocus の値を設定 +``` -

+## 例 -

HTML

+### HTML -
<select id="mySelect" autofocus>
-  <option>Option 1</option>
-  <option>Option 2</option>
-</select>
-
+```html + +``` -

JavaScript

+### JavaScript -
// Check if the autofocus attribute on the <select>
+```js
+//