Skip to content

Instantly share code, notes, and snippets.

@vitorpiovezam
Created August 6, 2019 01: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 vitorpiovezam/85295b88d7b44c005407c21c78f1262e to your computer and use it in GitHub Desktop.
Save vitorpiovezam/85295b88d7b44c005407c21c78f1262e to your computer and use it in GitHub Desktop.
$("a").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;
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment