jQuery Smooth Scroll to Anchor Using animate()

John Morris
jQuery Code Snippets
1 min readMay 26, 2016

I always get a kick out of jQuery… especially animation methods.

It’s one of those things that just wows clients… and truthfully, I feel pretty cool watching the animations run on a site.

That said, much of what you can do with jQuery animations is more than “eye-candy”… they help enhance the user experience.

This is one such animation: smoothing scrolling to an anchor tag.

Instead of that abrupt flash you get as default behavior in a browser… you get a nice smooth scroll that gives a site visitor some context about what they just clicked and where they’re ending up.

Here’s how to do it:

And, if you’d give me a likey-like I’d sure appreciate it!

And like I said the source code is available on Patreon for the smart folks who support the show. (You know you wanna join them.)

P.S. If you liked the show, give it a like and share with the communities and people you think will benefit. And, you can always find all my tutorials, podcast episodes and more on johnmorrisonline.com, @jpmorris on Twitter and youtube.com/johnmorrisvideo.

Subscribe to the Podcast

Originally published at John Morris.

--

--

John Morris
jQuery Code Snippets

I’m a web designer who helps other web designers with two things: 1) how to code and 2) how to market yourself so you can earn your living as a coder.