I include my header in every page like this
<?php include('header.php'); ?>
My jquery code looks like this
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
$('.nav').on('click', 'li', function(){
$('.nav li').removeClass('active-nav');
$(this).addClass('active-nav');
});
</script>
which is at the bottom of my index.php. The problem that occurs is that when I press directory (or home), the border (css active) is there for like 0.5 seconds then it disappears.
Here's the code in header.php and main.css (a part of it)
<ul class="nav navbar-nav">
<li><a href="index.php"><span class="glyphicon glyphicon-home"></span><span class="sr-only">Home</span></a></li>
<li><a href="directory.php"><span class="glyphicon glyphicon-th"></span> Directory</a></li>
</ul>
+
.navbar .active-nav {
border-bottom: 3px solid #4b7eb4;
}