Since you have not specifically asked for jQuery solution, here is one in plain javascript:
Let's assume that you have textarea
and div
, and you want to copy from textarea
to div
in realtime (same procedure is applicable to any other element in which you can type).
Html is this:
<textarea name="test" onkeyup="copyData(this,'copytarget')"></textarea>
<div id="copytarget"></div>
Then javascript is this:
function copyData(el, targ) {
document.getElementById(targ).innerHTML = el.value;
}
This simply copies everything typed into textarea
every time you lift a finger off the key on your keyboard.