如何在单击时更改菜单链接颜色[关闭]

Iam trying to change the background color of the link visited,

here is my header code

echo ('<ul>');
echo('<li><a href="'.$FromPage.'">Back</a></li>');  
echo('<li><a href="Talent_Hire.php">Hire</a></li>');    
echo('<li><a href="Talent_Hire.php">Hire</a></li>');
echo('<li><a href="Talent_Hire.php">Hire</a></li>');
echo('<li><a href="Talent_Hire.php">Hire</a></li>');
echo('</ul>');

i know we can try with javascript but not getting exctly how... please help me to fix this....

AS stated, this is a job for CSS + oh man, you code is wrong. Try something like this instead:

$string = '<ul>
             <li><a href="' . $FromPage . '">Back</a></li>
             <li><a href="Talent_Hire.php">Hire</a></li>
             <li><a href="Talent_Hire.php">Hire</a></li>
             <li><a href="Talent_Hire.php">Hire</a></li>
             <li><a href="Talent_Hire.php">Hire</a></li>
          </ul>';

echo $string;

And in you CSS file:

/** This will work only for tags `a` inside a `li` that is inside an `ul` tag.
    For all `a` tags, just remove the `ul` `li` part **/
ul li a:visited { background-color: #ff0000; }

This is something you do with CSS ( A:visited class) as you do not know if user visited this link or not. His browser might know. See this tutorial: http://www.echoecho.com/csslinks.htm for more information

Add this to your code:

echo('<style>');
echo('a:visited{');  
echo('color:red;');   
echo('}');  
echo('</style>');

Or if you get tired of using so many echos unnecessarily, you could just use:

echo '<style>
      a:visited{
          color:red;
      }
      </style>';