Last active
December 14, 2015 04:09
-
-
Save yramagicman/5026071 to your computer and use it in GitHub Desktop.
jquery function for single page web sites that facilitates navigation
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
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