Skip to content

Instantly share code, notes, and snippets.

@yassine-khachlek
Created April 17, 2015 16:39
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 yassine-khachlek/671991bb95e5cb432130 to your computer and use it in GitHub Desktop.
Save yassine-khachlek/671991bb95e5cb432130 to your computer and use it in GitHub Desktop.
Smooth Scrolling 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