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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically changing style.hover attributes ???

Status
Not open for further replies.

lagaye

Programmer
Apr 2, 2002
7
FR
Hello,

I'm a webmaster, and I am actually writing a little javascript tool to manage a menu.

I am trying to dynamically change some of my links attribute :

In my HTML code here's what you can find :
Code:
<a href=&quot;something_not_important&quot; class=&quot;MenuLinkClass1&quot; id=&quot;MyLink&quot;>

In javascript I would like to do is to change the &quot;class attribute of the link. I thought it should look like this :
Code:
MyLink.class = &quot;MenuLinkClass2&quot;;

On my stylesheet I use (for the classes for links) the Hover functionnality. Because the first method didn't work, I have tried the following :
Code:
MyLink.style.color = SomeColor;
MyLink.style.Hover.color = SomeOtherColor;

This didn't work either, and I can't find any information on the web. So I leave this question for you experts [tongue]

Thanks for any help
Lagaye[afro]
 
Lagaye,


First you should always reference your id'd items using document.getElementById like so :

document.getElementById(&quot;MyLink&quot;);

Secondly just add your hover inside your CSS class and it should work fine.

MenuLinkClass1:hover{
color: someColor ;
}

Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top