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

Change the bgcolor of one cell when mouseover aother cell in the table

Status
Not open for further replies.

MRALC

IS-IT--Management
Feb 21, 2002
8
GB
I am trying to do a mouseover so when you put a cursor over one cell it change the bgcolor of another cell it the table.

Al
 
Try using an id for the cell you want to change :

<style>
.onClass
{
color : white ;
background-color : Teal ;
}
.offClass
{
color: white ;
background-color : Purple ;
}

</style>

<script>
function getElement(id)
{
return document.all ? document.all[id] : document.getElementById(id) ;
}
</script>

<table>
<tr>
<td id=one onMouseOver=&quot;getElement('two').className = 'onClass'&quot; onMouseOut=&quot;getElement('two').className = 'offClass'&quot; class=offClass>Second</td>
<td id=two onMouseOver=&quot;getElement('three').className = 'onClass'&quot; onMouseOut=&quot;getElement('three').className = 'offClass'&quot; class=offClass>Third</td>
<td id=three onMouseOver=&quot;getElement('one').className = 'onClass'&quot; onMouseOut=&quot;getElement('one').className = 'offClass'&quot; class=offClass>First</td>
</tr>
</table>

Hope this helps. Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top