Last active
January 4, 2016 15:14
-
-
Save yuraloginoff/9c81c1415197f811e0ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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