I want to display a border line next to a tab when it is clicked or active. Currently, I am only able to show the line next to the tab that was initially selected, but it does not change dynamically with other tabs.
Here is my current implementation:
$(document).ready(function() {
$('.nav-link').each(function(){
var content_id = $(this).attr('href');
$(this).after($(content_id).hide());
if($(this).hasClass('active')) {
$(content_id).show();
}
});
$('.nav-link').on('click', function(){
var content_id = $(this).attr('href');
$('.tab-pane').hide();
$(content_id).show();
});
});
.child {
padding-left: 60px;
padding-right:100px
}
a.nav-link span {
position: relative;
}
a.nav-link.active span:before {
position: absolute;
content: "";
width: 25px;
height: 5px;
border-bottom: 4px solid #e64a19;
top: 8px;
left: -35px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div id="teams" class="tabbable tabs-left">
<div class="container">
<div class="row">
<nav class="nav flex-column col-md-1 teamTab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" href="#category1-tab" data-toggle="pill" role="tab"><span>Category1</span></a>
<a class="nav-link" href="#category2-tab" data-toggle="pill" role="tab"><span>Category2</span></a>
<a class="nav-link" href="#category3-tab" data-toggle="pill" role="tab"><span>Category3</span></a>
</nav>
<div class="tab-content col-md-11">
<div class="tab-pane child active" id="category1-tab">
<h5 class="card-title">Name</h5>
<p class="card-title">position</p>
</div>
<div class="tab-pane child" id="category2-tab">
<h5 class="card-title">Category 2 Name</h5>
<p class="card-title">position</p>
</div>
<div class="tab-pane child" id="category3-tab">
<h5 class="card-title">Category 3 Name</h5>
<p class="card-title">position</p>
</div>
</div>
</div>
</div>
</div>