Skip to content

Instantly share code, notes, and snippets.

@joelanman
Created September 16, 2013 11:11
Show Gist options
  • Save joelanman/6579327 to your computer and use it in GitHub Desktop.
Save joelanman/6579327 to your computer and use it in GitHub Desktop.
generic tabs in jquery
$('.tab a').on('click', function(e){
e.preventDefault();
var $this = $(this),
target = $this.attr('data-target'),
$tabWrap = $this.closest('.tab-wrap'),
$thisTab = $this.closest('.tab');
$tabWrap.find('.tab').removeClass('selected');
$tabWrap.find('.tab-content').hide();
$thisTab.addClass('selected');
$tabWrap.find('.tab-content-'+target).show();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment