Change Table cell background color (IE) : td « HTML Tags « JavaScript Tutorial






<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
function chgColor()
{
    var thistag, parentTag;
    thistag = window.event.srcElement.tagName;
    if (thistag == "TD")
    {
        document.all(window.event.srcElement.sourceIndex).bgColor = "lemonchiffon"
    }
}

function chgBack()
{
    var thistag, parentTag;
    thistag = window.event.srcElement.tagName;
    if (thistag == "TD")
    {
        document.all(window.event.srcElement.sourceIndex).bgColor = ""
    }
}
//  -->
</script>
</head>
<body onMouseover="chgColor()" onMouseout="chgBack()">
<table border="1" width="28%">
<tr>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
</tr>
<tr>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
</tr>
<tr>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
<td width="25%">&nbsp;</td>
</tr>
</table>
</body>
</html>








21.14.td
21.14.1.Set and clear table cell content
21.14.2.Change Table cell background color (IE)
21.14.3.Table cell onmouseover action event
21.14.4.Table cell onmouseout action event