Forum Moderators: open

Message Too Old, No Replies

link changing color

mouseover?

         

xxxxxpp

3:34 pm on Oct 11, 2004 (gmt 0)



Can anyone tell me what javascript code I should use to be able to have a link change from one color to another when you move your mousepoint over it, and back to the first color when you move your mouse away?

I think it's something with mousover or something like that.(total javascript noob here :))

MozMan

7:47 pm on Oct 11, 2004 (gmt 0)

10+ Year Member



I think the event you are looking for is onmouseover to change the color and onmouseout to change it back.

You might find it's easier to do this kind of thing with CSS tho...

-Moz

PanUK

8:04 pm on Oct 11, 2004 (gmt 0)

10+ Year Member



CSS would be better.

<STYLE TYPE="text/css">
<!-- TextRollover-1 -->
<!--
a:hover {text-decoration:none}
a:hover { color:#0066ff; text-decoration:none }
a:link { color:#ffffff; text-decoration:none }
a:visited { color:#EBF986; text-decoration:none }
-->
</STYLE>

Lance

8:19 pm on Oct 11, 2004 (gmt 0)

10+ Year Member



That's close, but your hover won't work if it comes first. The order is: Link, Visited, Hover, Active. It is a "LoVe/HAte" relationship. Oh, and the comment tags aren't needed either.

As long as "text-decoration:none" is on the first pseudoclass, it will "cascade" to the other pseudoclasses.

<style type="text/css">
a:link { color:#ffffff; text-decoration:none; }
a:visited { color:#EBF986; }
a:hover { color:#0066ff; }
</style>

xxxxxpp

8:32 pm on Oct 11, 2004 (gmt 0)



thanks for the help, I'm going to try it out right away :)

EDIT: worked like a charm. Thanks again, you guys rock! :D