//onchange function funName1(id) { $("#chgtxt").text($("#txt1").val()); } //onkeyup function funName2(id) { $("#chgtxt").text($("#txt2").val()); }
<body> <p>Result:<span id="chgtxt">Text</span></p> <p><!--onChange: change the Text content dynamically--> onChange:<input type="text" id="txt1" onChange="funName1(this.id);"/> </p> <p>--Similar example--</p> <p><!--onKeyUp: change the Text content dynamically and word by word --> onKeyUp: <input type="text" id="txt2" onKeyUp="funName2(this.id);"/> </p> </body>