PHP Tampilkan Halaman Aktif
$activePage = basename($_SERVER['PHP_SELF'], ".php");
Yawning Yak
$activePage = basename($_SERVER['PHP_SELF'], ".php");
<ul class="nav navbar-nav">
<li class="<?= ($activePage == 'index') ? 'active':''; ?>"><a href="index.php">Home</a></li>
<li class="<?= ($activePage == 'contact-us') ? 'active':''; ?>"><a href="contact-us.php">Contact</a></li>
</ul>
<script>
jQuery(function($){
$('.menu ul li a').filter(function() {
var locationUrl = window.location.href;
var currentItemUrl = $(this).prop('href');
return currentItemUrl === locationUrl;
}).parent('li').addClass('active');
});
</script>