Created
December 6, 2012 21:36
-
-
Save benjaminfisher/4228701 to your computer and use it in GitHub Desktop.
function to add active state to buttons in dynamically loaded content
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
var activeState = function(){ | |
var uriInfo = window.location.pathname.split("/"), | |
pageName = uriInfo[uriInfo.length-1], | |
buttons = $(this).find("li.button"), | |
$button, i; | |
i = buttons.length; | |
while(i--){ | |
$button = $(buttons[i]); | |
if($button.find("a").attr("id") === pageName){ | |
$button.addClass("active"); | |
break; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment