Skip to content

Instantly share code, notes, and snippets.

@terehof
Last active January 24, 2017 22:16
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 terehof/4b64b83a56fe5bcf5167 to your computer and use it in GitHub Desktop.
Save terehof/4b64b83a56fe5bcf5167 to your computer and use it in GitHub Desktop.
jq snippet smooth scrolling for anchors
$(document).ready(function() {
$("a.scrollto").click(function () {
elementClick = $(this).attr("href")
destination = $(elementClick).offset().top;
$("html:not(:animated),body:not(:animated)").animate({scrollTop: destination}, 1100);
return false;
});
});
// add "<a href="#section-2" class="scrollto">Section 2</a>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment