onchangeイベント
onchangeイベントは、入力できるタグエレメント内の値が変化したら発生するEventインターフェイスのイベントです。
似たイベントにoninputイベントがあります。違いは、oninputイベントは値が変化する度にscriptを実行します。onchangeイベントは値が変化しフォーカスを失ったらscriptを実行します。フォーカスを失った後で値が変化します。
onchangeイベントは<select>に対応しています。ラジオボタンやcheckboxタイプにおいても選択肢が変化したらscriptを実行します。
構文(Syntax)
in HTML
<tagelement onchange="oneFunction()">
in JavaScript
object.onchange = function(){ }; object.addEventListener("change", script_);
備考(Remarks)
Bubbles | Yes |
Cancelable | No |
Interface | Event |
Supported HTML Elements | <input type="checkbox">,<input type="color">,<input type="date">,<input type="datetime">,<input type="email">,<input type="file">,<input type="month">,<input type="number">,<input type="password">,<input type="radio">,<input type="range">,<input type="search">,<input type="tel">,<input type="text">,<input type="time">,<input type="url">,<input type="week">,<select>,<textarea> |
関連(Related)
HTML、CSS、DOMのFORMに関する用途一覧です。
HTML
- <fieldset>、 <form>、 <label>、 <legend>、 <output>
- button
- <button>
- 入力(input)
- <datalist>、 <input>、
- 選択(select)
- <optgroup>、 <option>、 <select>
- 文章編集(textarea)
- <textarea>
CSS
エレメントに関する用途一覧を参照して下さい。