Skip to content

Instantly share code, notes, and snippets.

@ryanapil
Created Apr 8, 2018
Embed
What would you like to do?
jQuery smooth scroll to # links
$(document).ready(function() {
$("a[href^='#']").on("click", function(event) {
event.preventDefault();
var target = this.hash,
$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