Last active
December 17, 2015 19:29
-
-
Save mikaelz/5660914 to your computer and use it in GitHub Desktop.
jQuery animated scroll to defined id specified by hash from URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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