Created
December 23, 2013 13:31
-
-
Save data-enhanced/8097183 to your computer and use it in GitHub Desktop.
Animate scroll to all page anchors within the page
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
// Animate scroll to all page anchors | |
$('[href^=#]').click(function (e) { | |
e.preventDefault(); | |
var div = $(this).attr('href'); | |
$("html, body").animate({ | |
scrollTop: $(div).position().top | |
}, "slow", "swing"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment