Skip to content

Instantly share code, notes, and snippets.

@yramagicman
Last active December 14, 2015 04:09
Show Gist options
  • Save yramagicman/5026071 to your computer and use it in GitHub Desktop.
Save yramagicman/5026071 to your computer and use it in GitHub Desktop.
jquery function for single page web sites that facilitates navigation
function scrollLocation( selectorString, id, linkLoc, offset) {
event.preventDefault();
var loc = window.location;
var url = loc.pathname;
window.location = url + linkLoc;
var scrollPos = $(document).scrollTop() - offset;
$(document).scrollTop(scrollPos);
$(selectorString).removeClass('active');
$(id).addClass('active');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment