Last active
May 29, 2019 14:14
-
-
Save hettiger/9035899 to your computer and use it in GitHub Desktop.
Simple smooth scrolling with 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
$(function () { | |
$("nav").find("a[href*=#]:not([href=#])").click(function () { | |
var offset = 0; | |
var speed = 1000; | |
var target = $(this.hash); | |
$("html,body").animate({ | |
scrollTop: target.offset().top - offset | |
}, speed); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting a console error that says "Uncaught TypeError: Cannot read property 'top' of undefined". Any ideas on why this is happening?