html - How to indicate that an LI with a link was pressed. -


i made menu , want keep pressed button different color. i.e. if @ menu page, menu button of menu blue.

i have read online guides menus , ended following:

<div id="menu">  <ul>      <li>         <a href="/index.php" >home</a>     </li>     <li>         <a href="/search.php" >search</a>     </li>     <li>         <a href="#">1</a>     </li>     <li>         <a href="#">2</a>     </li>     <li>         <a href="#">3</a>     </li>  </ul></div> 

and css this:

#menu ul li a.selected{ background:blue; color:#000; } 

of course every li has height , stuff has color. question how can tell html button selected? html attribute or something?

and dilemma have how best change these selected? can check address using php , change selected according it. suggestions how best it?

you go :

<li> <a href="/search.php"  <?php      if(strstr($_server["request_uri"], "yourpath/index.php"))        echo "class='selected'"; ?> > home </a> </li> 

or using javascript equivalent "document.url". might not cleanest solution should thing.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -