Created
May 22, 2012 15:49
-
-
Save ahmattox/2769906 to your computer and use it in GitHub Desktop.
Smooth scroll all links with internal anchors.
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
$(document).ready(function() { | |
$('a[href^="#"]').click(function(event) { | |
$('body').animate({ | |
'scrollTop': $($(this).attr('href')).position().top - 20 | |
}, 300); | |
event.preventDefault(); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment