◀︎STUDY JavaScript_007-1 input[type="text"]:focus フォーカスを当てる
1
-----
-----
-----
-----
focus (フォーカス)とは?
- ユーザーがフィールド(テキスト・ボックス内 / 入力欄) をクリックした状態
- フィールドの枠線がハイライト表示になる
- フィールドでカーソルが点滅する
- JavaScript で focus とはキーボード・イベントの行き先を決定すること
▼ Download: ■ sample_JS_007-ABCD
ほとんどのブラウザで focus されるタグは何か?
- <a>
- <input>
- <textarea>
- <button>
- <select>
- <details>
サンプル - 1
input タグに Attribute で type="text" を追加しただけ. 閉じタグはありません.
サンプル - 2
input タグと CSS で focus の outline で 値が none.
サンプル - 3
input タグと CSS で focus の outline で 値が solid 4px red.
サンプル - 4
input タグと JavaScript で ボタンを設置. querySelector("button") で focus させている.
focus を当てる例
<body onLoad="ふぉーむ.ふぉーかす.focus()">
<form name="ふぉーむ">
<input type="text"name="ふぉーかす"size="10">
</form>
</body>
ソース読み
タグ ボディ オンロードは ふぉーむ の中の ふぉーかす の中の focus化
タグ フォーム ネーム は ふぉーむ
インプット タイプ は テキスト ネーム は ふぉーかす
1
-----
-----
-----
-----
◀︎Contents STUDY JavaScript_007-1