JSFiddle - React, Tailwind, and code Playground
HTML
Input[type="text"]:
<br />
<input id="testInput" type="text" style="width: 302px;"></input>
<br />
Log:
<br />
<textarea id="log" style="width: 300px; height: 500px;"></textarea>
JavaScript
function inputValue(inputElement, eventHandler){
var scope = inputElement;
var timeoutHandler = function(scope, handler){
return setTimeout(function(){
Array.prototype.push.call(arguments, handler);
return scope.__internalValueCheckFunc.apply(scope, arguments);
}, 0);
};
inputElement.__internalValueCheckFunc = function(handler){
if(this.__internalValue != this.value){
this.__internalValue = this.value;
handler(this);
}
var scope = this;
timeoutHandler(scope, handler);
}
inputElement.__internalTimeoutHandler = timeoutHandler(inputElement, eventHandler);
}
inputValue(document.getElementById("testInput"), function(inputElem){document.getElementById("log").value = inputElem.value; });