Skip to content

Instantly share code, notes, and snippets.

@wireinet
Forked from agragregra/jQuery Tabs Short
Last active June 19, 2019 08:07
Show Gist options
  • Save wireinet/00b028165e330ed3a4d350b1674c2aac to your computer and use it in GitHub Desktop.
Save wireinet/00b028165e330ed3a4d350b1674c2aac to your computer and use it in GitHub Desktop.
Tabs on JQuery
HTML:
<div class="wrapper">
<div class="tabs">
<span class="tab">Вкладка 1</span>
<span class="tab">Вкладка 2</span>
<span class="tab">Вкладка 3</span>
</div>
<div class="tab_content">
<div class="tab_item">Содержимое 1</div>
<div class="tab_item">Содержимое 2</div>
<div class="tab_item">Содержимое 3</div>
</div>
</div>
<script>
$(".tab_item").not(":first").hide();
$(".wrapper .tab").click(function() {
$(".wrapper .tab").removeClass("active").eq($(this).index()).addClass("active");
$(".tab_item").hide().eq($(this).index()).fadeIn()
}).eq(0).addClass("active");
</script>
<style>
.wrapper .active { color: red; }
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment