Skip to content

Instantly share code, notes, and snippets.

@benjaminfisher
Created December 6, 2012 21:36
Show Gist options
  • Save benjaminfisher/4228701 to your computer and use it in GitHub Desktop.
Save benjaminfisher/4228701 to your computer and use it in GitHub Desktop.
function to add active state to buttons in dynamically loaded content
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