Tanmoy Sarkar Tanmoy Sarkar - 3 months ago 11
jQuery Question

PHP connection to make my li class active on evry page change

This is my Menu items .

<html>
<body>
<div class="container">

<ul class="nav navbar-nav ct-navbar--fadeIn">
<li class="active">
<a href="index.php?con=1">HEM</a>

</li>
<li><a href="index.php?con=3">OM OSS</a></li>
<li><a href="index.php?con=15">Vilkor</a></li>
<li><a href="index.php?con=16">Nyheter</a></li>

<li><a href="index.php?con=4">KONTAKTA OSS</a></li>



</ul>
<div class="clear"></div>
</div>

</body>
</html>


Curently it reamains active on home page even changing to other page. How could i able to make it active of that page on every page changing.



Thanks in advance.

Answer

try this

<?php
$myactiveli = $_GET['con'];
 ?>
<html>
    <body>
      <div class="container">

                        <ul class="nav navbar-nav ct-navbar--fadeIn">
                            <li <?php if($myactiveli==1) { echo 'class="active"'; } ?> >
                                <a href="index.php?con=1">HEM</a>

                            </li>
                            <li <?php if($myactiveli==3) { echo 'class="active"'; } ?>><a href="index.php?con=3">OM OSS</a></li>

                        </ul>
     <div class="clear"></div>
    </div>

    </body>
    </html>
Comments