Created
July 24, 2012 05:46
-
-
Save imjakechapman/3168260 to your computer and use it in GitHub Desktop.
quick little snippet to use on all of your anchors that are hooked to a Div ID
This file contains hidden or 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
| $(function($){ | |
| $('a').on('click', function(e){ | |
| var $anchor = $(this).attr("href"); | |
| var $hrefStart = $anchor.substr(0, 1); | |
| if ( $hrefStart == "#" ) { | |
| $('html,body').animate({ | |
| scrollTop: $($anchor).offset().top | |
| }, 1500, 'easeInOutExpo'); | |
| e.preventDefault(); | |
| } else { | |
| window.location.href = $anchor; | |
| } | |
| }); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment