Skip to content

Evavic44/jQuery-Smooth-Scroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smooth Scroll - jQuery

This is a simple illustration website to explain how smooth scrolling works and looks like.

Copy this script tag and paste in html page to use:

<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"></script>

jQuery block of code: 👇

{
// Smooth Scrolling
   $('#navbar a, .btn').on('click', function (e) {
      if (this.hash !== '') {
         e.preventDefault();

         const hash = this.hash;

         $('html, body').animate(
         {
            scrollTop: $(hash).offset().top - 100,
         },
         800
         );
      }
   });
}

About

A jQuery solution I use quite often for scrolling to same page links smoothly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published