Skip to content

Instantly share code, notes, and snippets.

@RiodeJaneiroo
Created October 2, 2018 14:35
Show Gist options
  • Save RiodeJaneiroo/d893e31ab1c224aed77dad888e0f8cc0 to your computer and use it in GitHub Desktop.
Save RiodeJaneiroo/d893e31ab1c224aed77dad888e0f8cc0 to your computer and use it in GitHub Desktop.
[Smooth Scroll to anchor] #js #scroll
$('a[href^="#"]').on('click', function(event) {
event.preventDefault();
var sc = $(this).attr("href"),
dn = $(sc).offset().top;
$('html, body').animate({scrollTop: dn}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment