Scroll textarea to top - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Scroll textarea to top

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  ww.j  av  a2s.  co  m*/
document.getElementById("b").onclick = function() {
    document.getElementById("t").scrollTop= 13;
    console.log(document.getElementById("t").scrollTop);
};
    }

      </script> 
   </head> 
   <body> 
      <textarea id="t" rows="10" cols="10">
        asd
        asdf
        asd
        fa
        sdf
        a
        sdfa
        sd
        fa
        sdf
        asd
        fa
        sd
        fa
        sdf
        asd
        fa
        sd
        f</textarea> 
      <button id="b">scrollTop</button>  
   </body>
</html>

Related Tutorials