Scroll down and top


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



Copy this code and paste it in your HTML
  1. <html xmlns="http://www.w3.org/1999/xhtml" >
  2. <head>
  3. <title>Scroll to Bottom or Top - DevCurry.com</title>
  4. <script type="text/javascript"
  5. src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js">
  6. </script>
  7. <script type="text/javascript" language="javascript">
  8. $(function () {
  9. $('#scrlBotm').click(function () {
  10. $('html, body').animate({
  11. scrollTop: $(document).height()
  12. },
  13. 1500);
  14. return false;
  15. });
  16.  
  17. $('#scrlTop').click(function () {
  18. $('html, body').animate({
  19. scrollTop: '0px'
  20. },
  21. 1500);
  22. return false;
  23. });
  24. });
  25. </script>
  26. </head>
  27. <body>
  28. <a id="scrlBotm" href="#">Scroll to Bottom</a>
  29. <div style="height:1000px"></div>
  30. <a id="scrlTop" href="#">Scroll to Top</a>
  31. </body>
  32. </html>

URL: http://www.devcurry.com/2010/10/use-jquery-to-scroll-to-bottom-or-top.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.