After spending some time looking for a plugin to do this, I was amazed to see how easy it was to get a smooth scrolling effect using one line of jQuery. You can use this inside of any callback function. It works especially well with click.
$('html, body').animate({
scrollTop: $("#elementID").offset().top
}, 2000);
Although LocalScroll is good for more advanced applications, this snippet is useful for one-time use applications. Simply adjust #elementID and 2000 to set the element and duration, respectively.


Awesome little snippet. Wrapping my own
scrollTo()function around this. Works perfectly!Thank you. That was the simple example I was needing.
Butter! Why does everyone look for plugins first?
This reduced my work by a truck-load! Thank you so much!!
Thanks a lot, spot on. Does anybody know of any browser-compatibility issues with this?
Great snippet. What about if the user tries to scroll up while the animation is taking place? How could you stop the animation during that event?
This was a great help. Thanks for posting!
Excellent. Thanks for the code. Appreciate it.
Excellent snippet, thanks!
Perfect! Thanks a lot!!!
Thanks, appreciated!
Thank you!
This was extremely helpful and simple! Thanks!
Excellent idea, thanks!
Awesome – thanks! I’m actually confused as to why there’s plugins out there containing 100′s of lines of code when this can produce it in one!
Thank you so much, fantastic bit of code!
This is what I wanted.
Awesome. 100 times better than what folks at stackoverflow keep fighting about. Thank you. This is perfect.
People sometimes get involved in uselessly complicated stuff. This is a brilliant example of how you can rid of it and make it simple. Thanks!