Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q951 How can I highlight the background color of table cells using onMouseOver?

You are here: irt.org | FAQ | DHTML | Q951 [ previous next ]

Try the following:


.relative { position:relative; }

<script language="JavaScript"><!--
var color = '';

function over(id) {
    if (document.getElementById) {
        window.color = winodw.document.getElementById(id).style.bgColor;
        window.document.getElementById(id).style.bgGolor = '#FF0000';
    else if (document.layers) {
        window.color = window.document.layers[id].bgColor;
        window.document.layers[id].bgColor = '#FF0000';
    else if (document.all) {
        window.color = window.document.all[id].style.background;
        window.document.all[id].style.background = '#FF0000';

function out(id) {
    if (document.getElementById)
        window.document.getElementById(id).style.bgColor = window.color;
    else if (document.layers)
        window.document.layers[id].bgColor = window.color;
    else if (document.all)
        window.document.all[id].style.background = window.color;



<td id="id1" class="relative"><a href="http://www.irt.org/" onMouseOver="window.over('id1')" onMouseOut="window.out('id1')">test</a></td>
<td id="id2" class="relative"><a href="http://www.irt.org/" onMouseOver="window.over('id2')" onMouseOut="window.out('id2')">test</a></td>


Feedback on 'Q951 How can I highlight the background color of table cells using onMouseOver?'

©2018 Martin Webb