Assign value from input box to <div> element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Assign value from input box to <div> element

Demo Code

ResultView the demo in separate window

<!doctype html>
<html>
   <head></head>
   <body> 
      <script>
        function myFunction()/*  www.ja va  2s  .  co  m*/
        {
            var input = document.getElementById('fname')
            var div = document.getElementById('text');
            div.innerHTML = escape(input.value);
        }
        
      </script> 
      <input type="text" id="fname" onkeyup="myFunction()"> 
      <div id="text"></div>  
   </body>
</html>

Related Tutorials