Jump to content

[SOLVED] Change Table Background Colour Using Javascript


stevesimo

Recommended Posts

Hi, I am trying to change the colour of a table background from white to red using javascript. I have attached an onmouseover event to a link so that when you move over the link the table background colour will change to red. I keep getting a script error message saying that an object is required but not sure what this means.

 

here is my code:

 


<script language="JavaScript">
function changeTableBackground(){ 
if(document.getElementsByTagName){ 
var mytable = document.getElementById(theTable); 
mytable.style.background = '#ff0000';
} 
}
</script>

<table width="600" height="400" align="center" border="1" id="theTable">
<tr><td></td></tr>
</table>
<br>
<a href="#" onMouseOver="changeTableBackground()">Change Table Background</a>


[code]

any help appreciated

thanks, steve

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.