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!

how do i change the rollover color of text when rolling over image?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how do i change the rollover color of certain text when rolling over an image? (using styles)

Debra
 
well, I would place the entire thing inside an href tag, and just change the a:hover style (though this will only work in IE4+,NS6, and probably Opera5):

<style>
a:hover {color:red}
</style>

<a href=&quot;javascript:;&quot;><img src=&quot;someimage.png&quot;>Hello</a>
jared@aauser.com -
 
here's an alternative:

<script>

function hoverText(whichdiv)
{
whichdiv.style.color='red'
}

function unHoverText(whichdiv)
{
whichdiv.style.color='blue'
}

</script>

<table>
<tr>
<td><img src=&quot;someimage.gif&quot; onmouseover=&quot;hoverText(mytext)&quot; onmouseout=&quot;unHoverText(mytext)&quot;></td>
<td><span id=&quot;mytext&quot;>Darg</span></td>
</tr>
</table> jared@aauser.com -
 
One thing i noticed, is that when i rollover the image above, and it changes the rollover color of the text, after that, when i rollover just the text, the style sheet hover doesnt work. It works if u rollover the text before the image. Any suggestions?
 
try adding this to the span:

onmouseover=&quot;hoverText(mytext)&quot;
onmouseout=&quot;unHoverText(mytext)&quot; jared@aauser.com -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top