Skip to content

Instantly share code, notes, and snippets.

@yuraloginoff
Last active January 4, 2016 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuraloginoff/9c81c1415197f811e0ee to your computer and use it in GitHub Desktop.
Save yuraloginoff/9c81c1415197f811e0ee to your computer and use it in GitHub Desktop.
<ul class="tab-nav">
<li><a href="#tab1">tab 1</a></li>
<li><a href="#tab2">tab 2</a></li>
<li><a href="#tab3">tab 3</a></li>
</ul>
<div class="tab-content">
<div class="panel" id="tab1">panel 1</div>
<div class="panel" id="tab2">panel 2</div>
<div class="panel" id="tab3">panel 3</div>
</div>
<script>
(function () {
$('.panel').hide().first().show();
$('.tab-nav a').on('click', function (e) {
e.preventDefault();
$(this).addClass('active').parent().siblings().find('a').removeClass('active');
var hash = $(this).attr('href').split('#')[1];
$('#'+hash).show().siblings().hide();
});
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment