Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- /* Code from Anthony Hull with revisions by Brian Katzung */
- jQuery('body').on('click', 'a[href*="#"]', function (ev) {
- /*
- * When clicking on a same-page hash...
- * (considering host+port+path match as same page)
- */
- if (this.host === location.host && this.pathname === location.pathname) {
- var hash = this.hash;
- ev.preventDefault(); // Prevent default click action (jump scroll)
- jQuery('html, body').animate({ // (Smooth scroll)
- scrollTop: jQuery(hash).offset().top
- }, 800 /* milliseconds */, function () {
- location.hash = hash; // Normalize URL upon arrival
- });
- }
- });
- </script>
Add Comment
Please, Sign In to add comment