Scrapbook Icon - Web Development
Web Development
Scrapbook Icon - Guided Tutorials
Guided Tutorials
1 Minute Read

Quite often, a web page has a key section that you want to push users towards. One method of doing this is to create a call to action that can be clicked and the page scrolls down to the section of interest.

When a transition is used, it can seamlessly direct the user towards completing a specific task. Here is a quick JS function that can be used to scroll a user to a specific element of the page:

The first parameter takes the selector of the element you want to scroll the user down to. The second option allows you to set a speed in milliseconds.

If you have a fixed navigation, you may need to deduct the height of the element too. For example, add ” – $(‘.navigation-element’).outerHeight()” after offset().top.