Click to See Complete Forum and Search --> : Change Link Color on MouseOver


mmartist
08-24-2003, 11:24 AM
:confused: Not a javascripter - am looking for a simple script to change a links color on mouseOver - example site http://javaboutique.internet.com/ where the links are in red and change to blue on mouseOver.
Would appreciate any help - thanks!
Lynn

Khalid Ali
08-24-2003, 11:28 AM
there are multiple approaches you can take.
1. use inline CSS for a specific link

<a href="someurl.html" onmouseover="this.style.color='red'">Link</a>

or u can set a specific rule for all anchor tags to follow
Put these lines in the head section of the page

<style type="text/css">
a:hover{
color:red;
}
</style>

David Harrison
08-24-2003, 11:32 AM
It's not javascript, you can use CSS for that. In the head put this:

<style type="text/css"><!--

a, a:link, a:visited{background:transparent;color:#f00;}
a:hover, a:focus, a:active{background:transparent;color:#fff;}

--></style>

This will apply to all links, if you only want it to apply to certain links add this to your a tags:

<a href="#" class="change">I'm a link</a>

And replace the style tag in the head with this:

<style type="text/css"><!--

a.change, a.change:link, a.change:visited{background:transparent;color:#f00;}
a.change:hover, a.change:focus, a.change:active{background:transparent;color:#fff;}

--></style>

mmartist
08-24-2003, 12:44 PM
Thanks - it works great!!!!


Lynn