Created
November 3, 2017 13:13
-
-
Save WebSofter/fbc12b0b875ad26a9084c57f15cc5927 to your computer and use it in GitHub Desktop.
Chrome hash link/anchor bag fixing
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
$("#menu-top-menu").find(".menu-item").click(function(){ | |
var hash = $(this).find("a").attr("href").split("#")[1]; | |
var hashNum = 0; | |
if (window.location.hash != ''){ | |
hashNum = window.location.hash.replace("#"+hash, ""); | |
console.log('hashNum: ' + hashNum); | |
}; | |
hashMenu = jQuery("#"+hash).offset().top; | |
jQuery('html,body').animate({ | |
scrollTop: hashMenu | |
}, 300); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment