Skip to content

Instantly share code, notes, and snippets.

@helinsv
Created June 23, 2017 13:29
Show Gist options
  • Save helinsv/d22fd288c7a542863e9b5d5a6552b317 to your computer and use it in GitHub Desktop.
Save helinsv/d22fd288c7a542863e9b5d5a6552b317 to your computer and use it in GitHub Desktop.
tabs
HTML:
<div class="tab_phone">
<div class="wrapper">
<div class="tabs">
<span class="tab">Москва</span> /
<span class="tab">Карганда</span>
</div>
<div class="tab_content">
<div class="tab_item">+7 (4722) 21-11-28</div>
<div class="tab_item">+7 (919) 439-56-89 </div>
</div>
</div>
</div>
jQuery:
$(document).ready(function(){
$(".tab_phone .tab_item").not(":first").hide();
$(".tab_phone .wrapper .tab").click(function() {
$(".tab_phone .wrapper .tab").removeClass("active").eq($(this).index()).addClass("active");
$(".tab_phone .tab_item").hide().eq($(this).index()).fadeIn()
}).eq(0).addClass("active");
});
CSS:
.tab_phone.active{
background-color: #a97d50;
color: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment