Skip to content

Instantly share code, notes, and snippets.

@katienelson
Last active March 9, 2016 12:05
Show Gist options
  • Save katienelson/9708b4af5391ca4850fc to your computer and use it in GitHub Desktop.
Save katienelson/9708b4af5391ca4850fc to your computer and use it in GitHub Desktop.
Smooth scrolling to internal links with jQuery. From http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment