try this JQUERY
first give the id
to your ul
<ul class="nav nav-tabs" id="nav_tabs">
then use jquery
$(document).ready(function(){
$('ul#nav_tabs li a').each(function(index, element) {
var li = $(element).attr('href');
$(element).parent().removeClass("active");
var filename = window.location.href.substr(window.location.href.lastIndexOf("https://stackoverflow.com/")+1);
if(filename==li)
{
$(element).parent().addClass("active");
}
});
});
also you can use PHP as
<?php
$my_url = $_SERVER['REQUEST_URI'];
$page = substr($my_url, strrpos($my_url, "https://stackoverflow.com/") + 1)
?>
<ul class="nav nav-tabs" id="nav_tabs">
<li <?php if($page=="https://stackoverflow.com/questions/21477563/admin.php") echo 'class="active"'; ?>><a href="https://stackoverflow.com/questions/21477563/admin.php">{"_MENUINFO"|lang}</a></li>
<li <?php if($page=="admin.php?site=ban_add") echo 'class="active"'; ?>><a href="admin.php?site=ban_add">{"_ADDBAN"|lang}</a></li>
<li <?php if($page=="admin.php?site=ban_add_online") echo 'class="active"'; ?>><a href="admin.php?site=ban_add_online">{"_ADDBANONLINE"|lang}</a></li>
</ul>
1
solved Jquery add li class active