Posted By

multani on 01/15/08


Tagged

scroll javascript DOM


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wnasich


scroll to top - JavaScript


 / Published in: JavaScript
 

URL: http://www.thescripts.com/forum/thread94146.html

This script can help you control the scroll of div by a simple function. Set thr property 'scrollTop' then the scoll can be controlled.

  1. <script language='javascript'>
  2.  
  3. function move_up() {
  4. scroll_clipper.scrollTop = 0;
  5. }
  6.  
  7. </script>
  8.  
  9. <a href='javascript:move_up()'>Move UP</a>
  10.  
  11. <p>
  12.  
  13. <div id='scroll_clipper'
  14. style='position:absolute; width:150px; height: 150px; overflow:auto'>
  15. <div id='scroll_text' style='background-color:yellow'>
  16. Here is some content that can be scrolled.
  17. <p>It uses two divs:<ul>
  18. <li>scroll_clipper, and
  19. <li>scroll_text
  20. </ul>
  21.  
  22. scroll_clipper defines the scroll area while scroll_text
  23. defines the text to be scrolled.
  24.  
  25. </div>
  26. </div>

Report this snippet  

You need to login to post a comment.