Put words from input text field value to div - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Put words from input text field value to div

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script language="JavaScript">
        var answer_var = '';
        var elem = '';
        function add_answers(elem){
          answer_var = elem.value+" ";
          document.getElementById('answer_div').innerHTML = document.getElementById('answer_div').innerHTML + answer_var;
        }// w  w w. j a  v  a  2 s.c  o  m
        
      </script> 
   </head> 
   <body> 
      <input type="text" id="answer_var" value="word" onclick="add_answers(this);"> 
      <div id="answer_div"></div>  
   </body>
</html>

Related Tutorials