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

Why won't my mouseOver work?

Status
Not open for further replies.

Trevahaha

Programmer
Nov 21, 2002
129
US
I have the following code that always worked on my previous sites, but not on this one. All I want is for the the links in this menu to change color.

<code>
<a href=&quot;URL&quot; class=&quot;menuoff&quot; onMouseOver=&quot;this.ClassName='menuon';&quot; onMouseOut=&quot;this.ClassName='menuoff';&quot;>LINK</a>
</code>
CSS:
.menuoff
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
color: #FFFFFF;
text-decoration: none;
font-weight: bold;
}

.menuon {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
color: #FF0000;
text-decoration: none;
font-weight: bold;
}

Here's the link to the website if you want to check out what I mean:

 
javascript is case sensitive
eg: should read this.className

also forum216 would be more appropriate in the furture for these types of questions.

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
I only wish I had a dollar for everytime i did that. I'd be rich.

no reason to feel like a idiot cause we all do it

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
CSS has built in pseudo classes (as it calls them) for dynamic reactions to stuff - a great example is with :hover.
It lets you do away with onMouseOver and corresponding onMouseOut event handlers.

So you could try:
Code:
HTML:
<a href=&quot;URL&quot; class=&quot;menu&quot;>LINK</a>

CSS:
.menu
 font-family: Verdana, Arial, Helvetica, sans-serif;
 font-size: 9px;
 color: #FFFFFF;
 text-decoration: none;
 font-weight: bold;
}

.menu : hover {
 color: #FF0000;
}

so, when the mouse is 'hovering' over an element with class=&quot;menu&quot; the contents of that element change color :)

bit simpler than the older way :) - let me know if i've typod, didn't actually test this
 
Yeah, I came across that and changed my site yesterday, funny you should post that. I do recommend this (anyone else who reads this), saves a heck of onMouseOver crap! :)


Trevor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top