if that certain link you clicked is navigating into an other html file then
only javascript is not enough.
you can add a class "selected" to your a tags with php play with some css.
<a href="link1.php" <?php if ( $_SERVER["SCRIPT_NAME"] == "link1.php" echo
"class=\"selected\"" ); ?>>link1</a>
<a href="link2.php" <?php if ( $_SERVER["SCRIPT_NAME"] == "link2.php" echo
"class=\"selected\"" ); ?>>link2</a>
<a href="link3.php" <?php if ( $_SERVER["SCRIPT_NAME"] == "link3.php" echo
"class=\"selected\"" ); ?>>link3</a>
a, a:visited {
color: darkblue;
}
a:hover, a.selected {
color: red;
}
maybe the / should be stripped from the script_name, dont remember.
I hope this was helpful.
2009/7/23 zephyr <[email protected]>
>
> Hello,
> I guess this is a simple css question but I ask this anyhow: I have a
> menu i a div id="menuTree" where each menuitemis a link. I want the
> menu to behave like this:
>
> Default a color of all links is is blue (should not be the default
> browser style but a custom style);
> The link hover is red;
> When a link is clicked it should change color (say to red) and stay
> red when the mouse leaves the link;
> When another link in the menu is clicked, the previously selected link
> should get the default color and the clicked link should get the
> selected color.
>
> I tried this with the a,a:hover,a:active,a:visited pseudo classes but
> it doesn't work.
>
> I tried this:
> // switch color to selected link
> var links=$("#menuTree a")
> for each(link in links){
> //$("#menuTree a").removeClass('linkSelected')
> $(link).addClass("linkDefault");
> }
> //$(this).addClass('linkSelected')
> $(link).toggleClass("linkSelected");
> e.stopPropagation()
> })
> Doesn't work. I don't know if it can be a css only solution
> (preferred) or if I need Javascript (that's ok). Can anyone point me
> in the right direction?
>
> Thanks!
>
> Marc
> >
>
--~--~---------~--~----~------------~-------~--~----~
--
You received this because you are subscribed to the "Design the Web with CSS"
at Google groups.
To post: [email protected]
To unsubscribe: [email protected]
-~----------~----~----~----~------~----~------~--~---