xxAlv1Nxx
06-27-2012, 03:20 PM
Hi, I am writing some code for a webpage. Essentially what I want this code to do is to change the text colour of an element and the background colour of another. I tried using the style object but I must have done something wrong because it's not working... I know that the script is retrieving the correct element so is there something wrong with my syntax for the style object?
<script type="text/javascript">
function hover(x)
{
var k=document.getElementById(x);
this.style.color="#000000";
k.style.backgroundColor="#000000";
}
</script>
...
<table><tr>
<td style="background-color:#aaaaaa;" id="a"/>
</tr>
<tr style="color:#aaaaaa;">
<td onMouseOver="hover('a')">home</td>
</tr></table>
Thank you!
<script type="text/javascript">
function hover(x)
{
var k=document.getElementById(x);
this.style.color="#000000";
k.style.backgroundColor="#000000";
}
</script>
...
<table><tr>
<td style="background-color:#aaaaaa;" id="a"/>
</tr>
<tr style="color:#aaaaaa;">
<td onMouseOver="hover('a')">home</td>
</tr></table>
Thank you!