Add input event handler to <textarea> - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Add input event handler to <textarea>

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <textarea id="list" placeholder="Enter your list"></textarea> 
      <script>
var textarea = document.getElementById('list');
var arr = [];//from   ww  w.j av  a  2s .com
textarea.addEventListener('input', function () {
    arr = this.value.split('\n');
    console.log(arr);
}, false);

      </script>  
   </body>
</html>

Related Tutorials