Skip to content

Instantly share code, notes, and snippets.

@reinh
Created November 18, 2010 03:41
Show Gist options
  • Select an option

  • Save reinh/704592 to your computer and use it in GitHub Desktop.

Select an option

Save reinh/704592 to your computer and use it in GitHub Desktop.
$.fn.subnavTabs = function(options) {
var opts = $.extend({}, $.fn.subnavTabs.defaults, options);
return this.each(function() {
var self = $(this),
items = self.children('li'),
links = items.children('a')
tabs = $(opts['target']),
show_active = function() {
tabs.children('div.box').hide();
$(items.filter('.active').children('a').attr('href')).show();
},
set_active = function(obj) {
items.removeClass('active');
obj.parent('li').addClass('active');
};
show_active();
links.click(function() {
set_active($(this));
show_active();
return false;
});
});
};
$.fn.subnavTabs.defaults = {};
$(document).ready(function() {
$('#app-sub-nav').subnavTabs({'target': '#tab-boxes'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment