Created
February 21, 2018 14:30
-
-
Save 1-800-jono/e48ce1ab9ce51ed8ab4fa98247c04e24 to your computer and use it in GitHub Desktop.
Smooth scrolling using anchor tags - jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////// | |
//Smooooth scrolling | |
//////////////// | |
var root = jQuery('html, body'); | |
jQuery('.menu li a').click(function() { | |
var href = jQuery.attr(this, 'href'); | |
var offset = jQuery(href).offset(); | |
var scrollto = offset.top - 100; // 100 here is the offsetb needed bacause of top sticky nav | |
root.animate({ | |
scrollTop: scrollto | |
}, 600, ); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment