jinni
jinni

Reputation: 227

How to change active menu item style in html/css/js/php

heres how my html is

<ul class="navigation">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?content=about">About us</a></li>
</ul>

as you can see the content of "about us" page is loaded in to index.php. now i want to change active page link on nav bar different style.

please do help me. i hope this question is clear.

Upvotes: 0

Views: 1253

Answers (1)

Dave
Dave

Reputation: 1001

to add a class to a particular item based on selection;

<ul class="navigation"> 
<li <?php if(!isset($_GET['content'])) { echo 'class="active"'; } ?>><a href="index.php">Home</a></li> 
<li <?php if(isset($_GET['content']) && $_GET['content']=='about') { echo 'class="active"'; } ?>><a href="index.php?content=about">About us</a></li> 
</ul>

Upvotes: 2

Related Questions