入力イベントを監視したい場合に使うイベントはどれですか?
[ html ]
<input type="text" id="nameInput">
- click
- keydown
- input
- submit
正解
- input
解説
inputイベントはユーザーが入力フィールドの値を変更するたびに発生します。リアルタイムの検出に有効です。
使用例(サンプルコード)
[ javascript ]
const input = document.getElementById("nameInput");
input.addEventListener("input", (e) => {
console.log("入力値:", e.target.value);
});