ultrasound0000 Posted March 9, 2009 Share Posted March 9, 2009 I'm implementing PHP header & footer includes throughout my website. However some items in my header include file will change their CSS state/class depending on what section/page the visitor is in. For example, the header file includes my site's main navigation menu among other things. Let's say the navigation menu has 5 items total and each of the menu items has an active state when a user clicks to visit that particular section. This active state is set through CSS, something like: <ul class="nav"> <li><a href="../menu1stuff/" class="menu1">Menu One</a></li> <li class="active"><a href="../menu2stuff/" class="menu2">Menu Two</a></li> <li><a href="../menu3stuff/" class="menu3">Menu Three</a></li> <li><a href="../menu4stuff/" class="printnow">Menu Four</a></li> <li><a href="../menu5stuff/" class="menu5">Menu Five</a></li> </ul> Notice the active class on the <li> tag. How can I dynamically set the active class when using the header file so if visitors is on Menu One than Menu One is set to active, if on Menu Two than Menu Two is set to active and so on ... I'm trying to figure out an efficient way to accomplish this. Any suggestions greatly appreciated. I can use JavaScript and PHP. Quote Link to comment Share on other sites More sharing options...
ultrasound0000 Posted March 10, 2009 Author Share Posted March 10, 2009 anyone? Quote Link to comment Share on other sites More sharing options...
php_east Posted March 10, 2009 Share Posted March 10, 2009 http://www.java2s.com/Code/HTMLCSS/CSS-Attributes-and-Javascript-Style-Properties/activeExample.htm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.