Set a class for an element in a PHP include()

Posted by paracaudex on Stack Overflow See other posts from Stack Overflow or by paracaudex
Published on 2010-04-09T17:50:55Z Indexed on 2010/04/09 17:53 UTC
Read the original article Hit count: 271

I have an identical horizontal menu at the top of all of my pages, which I add using a PHP include() statement. In my stylesheet I want to have a class where if the user is on a particular page, the menu item corresponding to that page will have a different color. So, more or less:

#dropdown { background-color:blue; }

#dropdown .active { background-color:green; }

But, since the menu comes from the PHP include, it's always the same. How can I write some PHP or JavaScript that adds class="active" to the appropriate menu item for each page?

© Stack Overflow or respective owner

Related posts about menubar

Related posts about server-side-includes