add class active to menu in header.php -


i trying add class=active menu when page accessed user.

i have code menu:

<!-- main nav --> <div class="header-nav navbar-collapse collapse">     <ul class="nav navbar-nav">         <li class="active"><a href="studenti.php">acasa<i                 class="fa fa-chevron-down"></i></a>          </li>         <li><a href="noutati.php">anunturi si noutati<i                 class="fa fa-chevron-down"></i></a>          </li>         <li><a href="burse.php">burse<i class="fa fa-chevron-down"></i></a>          </li>         <li><a href="orar.php">orar<i class="fa fa-chevron-down"></i></a>          </li>         <li><a href="cazari.php">cazari<i class="fa fa-chevron-down"></i></a>          </li>          <li><a href="javascript:;">acces <i class="fa fa-chevron-down"></i></a>             <ul class="sub-menu">                 <li><a href="#">traiectorie scolara</a></li>                 <li><a href="#">idfr</a></li>             </ul>         </li>     </ul> </div> 

what settings need in order have link menu/page when page visited highlighted active?

i`m using header.php global header config.

you can detect page splitting end of url:

var url = window.location; var page = url.split('/'); page = page.slice(-1).pop(); 

then detect condition e.g.

if(page == 'burse.php') {     $('.active').removeclass('active');     $('nav li:nth-child(3)').addclass('active'); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -