Skip to content

Instantly share code, notes, and snippets.

@TheCodonist
Created May 12, 2023 07:13
Show Gist options
  • Save TheCodonist/8097ec306e2c61f97acdc4b4cdc8dfa7 to your computer and use it in GitHub Desktop.
Save TheCodonist/8097ec306e2c61f97acdc4b4cdc8dfa7 to your computer and use it in GitHub Desktop.
$(".scroll-to").on('click', function(event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
window.location.hash = hash;
});
} // End if
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment