scroll to top - JavaScript


/ Published in: JavaScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.