Skip to content

Instantly share code, notes, and snippets.

@karamanskiy
Forked from agragregra/jQuery Tabs Short
Last active May 23, 2021 06:26
Show Gist options
  • Save karamanskiy/2fdb7721ccf16626ef6ecdbe0a395403 to your computer and use it in GitHub Desktop.
Save karamanskiy/2fdb7721ccf16626ef6ecdbe0a395403 to your computer and use it in GitHub Desktop.
Простые табы
HTML:
<div class="tabs-wrapper">
<div class="tab_header">
<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>
jQuery:
$(".tab_item").not(":first").hide();
$(".tabs-wrapper .tab").click(function() {
$(".tabs-wrapper .tab").removeClass("active").eq($(this).index()).addClass("active");
$(".tab_item").hide().eq($(this).index()).fadeIn()
}).eq(0).addClass("active");
CSS:
.tabs-wrapper .active { color: red; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment