Skip to content

Instantly share code, notes, and snippets.

@WebSofter
Created November 3, 2017 13:13
Show Gist options
  • Save WebSofter/fbc12b0b875ad26a9084c57f15cc5927 to your computer and use it in GitHub Desktop.
Save WebSofter/fbc12b0b875ad26a9084c57f15cc5927 to your computer and use it in GitHub Desktop.
Chrome hash link/anchor bag fixing
$("#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