PDA

View Full Version : Cell Mouseover - Change link color?


bostjank
04-07-2004, 08:13 AM
Hi!

Is it possible to change color of the link in a cell on cell mouseover event? How?

Thanks,
Bostjan

Kor
04-07-2004, 09:30 AM
Yes, change style "on-the-fly" on event


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
function setup(){
document.getElementById('link').style.color = '#FF0000'
}
function change(){
document.getElementById('link').style.color = '#FF00FF'
}
window.onload=setup
</script>
</head>
<body>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#CCCCCC" onmouseover="change()" onmouseout="setup()"><a href="#" id="link">text</a><br>
</td>
</tr>
</table>
</body>
</html>

bostjank
04-07-2004, 09:42 AM
Thanks.

Choopernickel
04-07-2004, 02:02 PM
Another way (impossible in IE without the PseudoClassesFix (http://www.vladdy.net/Demos/IEPseudoClassesFix.html)) is to use purely CSS.

<style type="text/css">
td.nav a {
color: #000;
background-color: #fff;
}
td.nav:hover a {
color: #fff;
background-color: #800;
}
</style>
...
<table>
<tr>
<td class="nav"><a href="#">text</a></td>
</tr>
</table>