Holding DOM elements in variables - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Holding DOM elements in variables

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w w .  ja  v a2 s. c  o m*/
var textarea = document.getElementById("myTextarea");
var words = textarea.value;
var button = document.getElementById("myButton");
button.addEventListener("click", function() {
    console.log(words);
});
    }

      </script> 
   </head> 
   <body>
       Enter here 
      <input id="myTextarea"> 
      <button id="myButton" type="submit"> test </button>  
   </body>
</html>

Related Tutorials