DOM

InputEvent.data プロパティ

 編集:2022.10.04 by T.A.

[Edge]。読取専用。→

InputEvent で文字が挿入された文字列を返します。

変更によってテキストが挿入されない場合、これは空の文字列になる可能性があります。文字を削除したときなど。

構文
InputEvent.data

文字列。

HTML:

<INPUT id=IdTest><BR>
<SPAN id=IdTest2 contenteditable>[SPAN要素。編集可能]</SPAN><BR>
<SPAN id=IdLog></SPAN>

JavaScript:

function Job(eve){ //inputイベントの処理:
  D=eve; //=[object]:[object InputEvent]。INPUT要素でATOKを介して「あい」とキー入力してみた。
詳細 //isTrusted=[boolean]:true //data=[string]:あい //isComposing=[boolean]:false //inputType=[string]:insertText //dataTransfer=[object]:null //getTargetRanges=[function]:function getTargetRanges() { [native code] } //view=[object]:null //detail=[number]:0 //sourceCapabilities=[object]:null //which=[number]:0 //initUIEvent=[function]:function initUIEvent() { [native code] } //type=[string]:input //target=[object]:[object HTMLInputElement] //currentTarget=[object]:null //eventPhase=[number]:0 //bubbles=[boolean]:true //cancelable=[boolean]:false //defaultPrevented=[boolean]:false //composed=[boolean]:true //…
IdLog.innerHTML=eve.data; //表示。 } IdTest.oninput=Job; //イベント割り当て。 IdTest2.oninput=Job; //イベント割り当て。

テスト