Implementing smooth scrolling

Anchor links to navigate to different sections of the page are useful to allow users to easily bypass the information in which they are not interested and go directly to that in which they are. However, when there is a lot of textual data on the screen, jumping between these different sections can often be confusing for the user. Using smooth scrolling and animating the screen to slowly move up or down to the selected section, it is easier for a user to visualize where they have navigated to without getting disorientated.

Getting ready

Simply create the three standard recipe files, recipe-4.html, recipe-4.css, and recipe-4.js, and save them to the same directory as the latest version of the jQuery library.

How to do ...

Get jQuery 2.0 Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.