Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Last active December 17, 2015 19:29
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 mikaelz/5660914 to your computer and use it in GitHub Desktop.
Save mikaelz/5660914 to your computer and use it in GitHub Desktop.
jQuery animated scroll to defined id specified by hash from URL
/*
Additional info
http://stackoverflow.com/a/7717572/289404
http://stackoverflow.com/a/3379169/289404
*/
(function ($) {
if ( window.location.hash == '#reference' ) {
$('html, body').animate({
scrollTop: $( '#reference' ).offset().top
}, 1000);
}
}( jQuery ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment