Created
April 17, 2015 16:39
-
-
Save yassine-khachlek/671991bb95e5cb432130 to your computer and use it in GitHub Desktop.
Smooth Scrolling To Internal Links With jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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