Skip to content

Instantly share code, notes, and snippets.

@jeffreysfridge
Last active August 8, 2016 17:12
Show Gist options
  • Select an option

  • Save jeffreysfridge/7e111ebac091c65cda25 to your computer and use it in GitHub Desktop.

Select an option

Save jeffreysfridge/7e111ebac091c65cda25 to your computer and use it in GitHub Desktop.
Smooth Scroll to Anchor
$(".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