Scroll Textarea to the bottom - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Scroll Textarea to the bottom

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(){// w ww  .  j a  v a2s. c om
var textarea = document.getElementById('textarea_id');
setInterval(function(){
    textarea.value+=Math.random()+'\n';
    textarea.scrollTop = textarea.scrollHeight;
}, 1000);
    }

      </script> 
   </head> 
   <body> 
      <textarea id="textarea_id" columns="10" rows="5">
</textarea>  
   </body>
</html>

Related Tutorials