Skip to content

Instantly share code, notes, and snippets.

@Korveld
Last active April 6, 2021 13:00
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 Korveld/f4197aa9c8269b057b2744e4b8b8087b to your computer and use it in GitHub Desktop.
Save Korveld/f4197aa9c8269b057b2744e4b8b8087b to your computer and use it in GitHub Desktop.
$('.js-scroll-to').on('click', function(e) {
e.preventDefault()
$('html, body').animate({
scrollTop: $($(this).attr('href')).offset().top
}, 1000);
})
if ($(window.location.hash).length > 1) {
$("html, body").animate({
scrollTop: $(window.location.hash).offset().top
}, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment