Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change link color with onMouseOver

Status
Not open for further replies.

eharris

Programmer
Mar 13, 2001
15
0
0
Using:

<script language=JavaScript1.2><!-- Hide the script from old browsers --
document.write('<style type=&quot;text/css&quot;>A:hover{color: #9C6500}</style>')
//----------------></script>

. . .I can change the color of a link when moving the mouse over it. But this affects every link on the page, and does not remove the underline of the link.

How can I use JavaScript to change the color of select links on mouseOver and remove the underline at the same time?

Thank you in advance.

Ed
 
<a href=&quot;blah.htm&quot; onmouseover=&quot;this.style.color = 'red'&quot; onmouseout=&quot;this.style.color = 'blue';&quot;>dsfsadf</a>

luciddream@subdimension.com
 
<a href=&quot;blah.htm&quot; onmouseover=&quot;this.style.color = 'red';this.style.textDecoration = 'none';&quot; onmouseout=&quot;this.style.color = 'blue';this.style.textDecoration = 'underline';&quot;>dsfsadf</a>
luciddream@subdimension.com
 
You don't need to bother with the mouseovers. Just create a special style class for the hover attribute of anchors you want different and apply that to the special ones. Try this:
Code:
<style type=&quot;text/css&quot;>
A:hover.special{color: #9C6500; text-decoration:none;}
</style>

<a href=&quot;normal.html&quot;>this is normal</a><br>
<a href=&quot;special.html&quot; class=&quot;special&quot;>this is special</a><br>
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top