Skip to content

Instantly share code, notes, and snippets.

@douglogue
Created October 22, 2013 14:40
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 douglogue/7101897 to your computer and use it in GitHub Desktop.
Save douglogue/7101897 to your computer and use it in GitHub Desktop.
Smooth scroll to in-page elements
<script>
$(document).ready(function(){ $('a').click(function(){ goToByScroll($(this).attr('href')); return false; }); });
function goToByScroll(id){ $('html,body').animate({scrollTop: $(id).offset().top},'slow'); }
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment