Forum Moderators: open

Message Too Old, No Replies

how do I get a:hover's color: value?

         

cuce

3:57 pm on May 29, 2006 (gmt 0)

10+ Year Member



how do I determine what the value of color: for a:hover is?

texmex

11:33 pm on May 30, 2006 (gmt 0)

10+ Year Member



Set it to something in your CSS, then it's a pretty safe bet that it will be that colour?

What are you trying to achieve?

cuce

8:41 pm on May 31, 2006 (gmt 0)

10+ Year Member



I'm trying to make it so by clicking on for example one link, you can change the value in the css for the hover state.

say a:hover{color:#333;}

when I click my link I want it to be set as
a:hover{color:#000;}

texmex

9:11 pm on Jun 1, 2006 (gmt 0)

10+ Year Member



What i'd suguest is that you change the className of the anchor in your event handler. You can then specify it's new hover attributes within a separate part of you CSS.

The following demonstrates:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<HEAD>
<style type="text/css">
A
{font-weight:bold;
text-decoration:none;color:blue;}

A:hover
{color:red;}

A.Aclicked
{color:black;}

A.Aclicked:hover
{color:green;background-color:yellow;}
</style>

<script type="text/javascript">
function changeHover(element)
{
element.className="Aclicked";
return false;
}

</script>

</HEAD>

<BODY>
<A href="http://whatever.com" onclick="return changeHover(this)">
Here's an example Anchor</a>
</body>
</html>


I have chosen to use some more noticable colour variations, to highlight what is happening. Obviously you'll want to tone it down a bit for your application.