Book Image

jQuery 2.0 Development Cookbook

By : Leon Revill
Book Image

jQuery 2.0 Development Cookbook

By: Leon Revill

Overview of this book

Table of Contents (17 chapters)
jQuery 2.0 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 it…

Perform the following simple steps to add smooth scrolling to a website or web page:

  1. Create a long web page by adding the following HTML code to recipe-4.html:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Chapter 6 :: Recipe 4&lt...