Created
December 7, 2012 09:07
-
-
Save passcod/4232002 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<script type="text/javascript" src="jquery.min.js"></script> | |
<script type="text/javascript" src="script.js"></script> | |
<style> | |
nav#main a[data-current] { color: red; } | |
</style> | |
<nav id="main"> | |
<a href="#!/">A</a> | |
<a href="#!/derp">B</a> | |
<a href="#!/herp">C</a> | |
</nav> |
This file contains hidden or 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() { | |
var doNavigate = function(section) { | |
section = section || window.location.href.split("#!/")[1] || ""; | |
section = section.target === undefined ? "#!/" + section : section.target.hash; | |
$("nav#main a") | |
.removeAttr("data-current") | |
.filter("[href='"+ section +"']") | |
.attr("data-current", ""); | |
}; | |
$("nav#main").on("click", "a", doNavigate); | |
doNavigate(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment