Last active
August 8, 2016 17:12
-
-
Save jeffreysfridge/7e111ebac091c65cda25 to your computer and use it in GitHub Desktop.
Smooth Scroll to Anchor
This file contains hidden or 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
| $(".scroll").click(function(event){ | |
| event.preventDefault(); | |
| $('html,body').animate({scrollTop:$(this.hash).offset().top}, 500); | |
| }); | |
| /* target any href with '#' */ | |
| $("a[href^='#']").click(function(event){ | |
| event.preventDefault(); | |
| if (this.hash.substr(1) != ''){ | |
| $('html,body').animate({scrollTop:$(this.hash).offset().top}, 500); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment