Skip to content

Instantly share code, notes, and snippets.

@agragregra
Last active November 23, 2023 14:47
Show Gist options
  • Star 83 You must be signed in to star a gist
  • Fork 91 You must be signed in to fork a gist
  • Save agragregra/e0ad62a2a901e615c89a to your computer and use it in GitHub Desktop.
Save agragregra/e0ad62a2a901e615c89a to your computer and use it in GitHub Desktop.
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>
jQuery:
$(".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");
CSS:
.wrapper .active { color: red; }
@dizavi
Copy link

dizavi commented Jan 20, 2018

Спаибо!!!

@Olegwdevby
Copy link

Работает!

@vetaluga
Copy link

vetaluga commented Nov 6, 2018

Спасибо

@YakovSPb
Copy link

not cool

@pestovpvl
Copy link

От души!

@Delleron
Copy link

Всё прекрасно работает но когда каждый .tab находиться в классе Bootstrap (.col-lg-2), то не работает переключение. Как бы это можно было исправить?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment