Skip to content

Instantly share code, notes, and snippets.

@ivandoric
Created April 23, 2014 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivandoric/11215077 to your computer and use it in GitHub Desktop.
Save ivandoric/11215077 to your computer and use it in GitHub Desktop.
jQuery: Smooth scroll
jQuery('a[href^="#"]').bind('click.smoothscroll',function (e) {
e.preventDefault();
var target = this.hash;
$target = jQuery(target);
jQuery('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 500, 'swing', function () {
window.location.hash = target;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment