Skip to content

Instantly share code, notes, and snippets.

@danomanion
Last active October 11, 2015 13:47
Show Gist options
  • Save danomanion/3867880 to your computer and use it in GitHub Desktop.
Save danomanion/3867880 to your computer and use it in GitHub Desktop.
JS Ghetto Scroll to ID and move 50 pixels up
$(function(){
var win = $(window); //cache your jq objects!
function fixScrollTop(){
win.scrollTop(win.scrollTop() - 50);
}
if(window.location.hash !== ""){
fixScrollTop();
}
win.bind('hashchange', fixScrollTop);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment