Posted By

1man on 01/12/10


Tagged

scroll page jquery


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

netzwerktourist
vagrantradio
koyotebr
jarc100
symsec


Simple jQuery page scroller


 / Published in: jQuery
 

Example in 'jQuery enlightenment'

Simple way to jump smoothly down the page without the use of a plugin.

  1. /**
  2.  * HTML setup as a list of anchors set vertically down the page
  3.  */
  4.  
  5. //Click an anchor
  6. $("a").click(function(e){
  7. //Animate the html and body
  8. $("html, body").animate({
  9. //Set the CSS property scrollTop to the next anchors top value
  10. scrollTop: $(this).parent('li').next().find("a").offset().top
  11. }, 1000);//1 second scroll (add some easing for a smoother look)
  12. return false;
  13. });

Report this snippet  

You need to login to post a comment.