Currently, I am in the process of developing tabs using solely jQuery without incorporating any third-party plugins.
jQuery(document).ready(function(){
$(".resp-tab-content").hide();
$("ul.resp-tabs-list li:first").addClass("active").show();
$(".resp-tab-content:first").show();
$("ul.resp-tabs-list li").click(function()
{
$("ul.resp-tabs-list li").removeClass("active");
$(this).addClass("active");
$(".resp-tab-content").hide();
var activeTab = $(this).find("span").attr("href");
$(activeTab).fadeIn();
return false;
});
});
ul.resp-tabs-list {
list-style: none;
background: none;
margin: 0 auto;
padding: 0;
border-bottom: solid 1px #EAEAEA;
}
.resp-tab-item {
color: #343a4e;
font-size: .875em;
cursor: pointer;
padding: 0 .6em .5em;
display: inline-block;
list-style: none;
float: left;
border-bottom: solid 1px #FFFFFF;
outline: none;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
text-transform: capitalize;
}
.resp-tab-active {
text-shadow: none;
color: #1ca0de;
border-bottom: solid 1px #3E9CCA;
padding-bottom: .5em;
}
.resp-tabs-container {
padding: 0px;
clear: left;
border-top: none;
background: none;
}
.tab-content {
margin: 1em 0 0 0;
border-bottom: solid 1px #EAEAEA;
padding-bottom: 1em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="horizontalTab" style="display: block; margin: 0px; width: 100%;">
<ul class="resp-tabs-list">
<li class="resp-tab-item resp-tab-active"><span>Today</span></li>
<li class="resp-tab-item"><span>This Week</span></li>
<li class="resp-tab-item"><span>This Month</span></li>
</ul>
<div class="resp-tabs-container">
<div class="resp-tab-content resp-tab-content-active" style="display:block"><div class="tab-content">a</div></div>
<div class="resp-tab-content"><div class="tab-content">b</div></div>
<div class="resp-tab-content"><div class="tab-content">c</div></div>
</div>
</div>
Inspired by this example here, I decided to forego the use of the label <a>
and instead utilize the label <span>
for displaying tab content.
Encountering an error in the code, as clicking on existing tabs fails to hide the content or execute properly.
Although I successfully replicated the design, functionality is lacking, and there is a minor flaw in the layout with the gray border appearing above rather than below the text representing each tab.