Skip to content

Instantly share code, notes, and snippets.

@data-enhanced
Created December 23, 2013 13:31
Show Gist options
  • Save data-enhanced/8097183 to your computer and use it in GitHub Desktop.
Save data-enhanced/8097183 to your computer and use it in GitHub Desktop.
Animate scroll to all page anchors within the page
// 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