My recommendation is to utilize jQuery and apply a click event to all <a>
elements within the element that has the class breadcrumb
:
$('.breadcrumb > a').on('click', function() {
$('.breadcrumb > a').removeClass('active');
$(this).addClass('active');
})
By using the CSS rule active
, you can remove the 'active' class when a tab is clicked, and then add the class 'active' to the one that was just clicked.
$('.breadcrumb > a').on('click', function() {
$('.breadcrumb > a').removeClass('active');
$(this).addClass('active');
})
.active {
background: #444
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<style>
/* CSS styles here */
</style>
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="breadcrumb flat">
<!-- Breadcrumb links -->
</div>
<div class="breadcrumb flat">
<!-- More breadcrumb links -->
</div>
</div>
</div>
</body>
</html>