Skip to content

Instantly share code, notes, and snippets.

@revans
Created October 22, 2010 00:59
Show Gist options
  • Save revans/639719 to your computer and use it in GitHub Desktop.
Save revans/639719 to your computer and use it in GitHub Desktop.
// Tab Highlighting Function
//
// Usage:
//
// $(document).ready(function(){
// $.tab_highlight();
// });
//
(function($) {
$.tab_highlight = function() {
$.tab_highlight.init();
}
$.extend($.tab_highlight, {
init: function() {
var current_path = location.pathname;
$(".tab_highlight").each(function() {
var anchor_path = $(this).children().first().attr('href');
if(anchor_path == current_path) {
$(this).addClass('active');
} else {
$(this).removeClass("active");
}
});
}
});
$.fn.tab_highlight = function() {
$.tab_highlight.init();
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment