[thelist] DOM: accessing properties of "group" array

Duncan O'Neill dbaxo at ihug.co.nz
Tue Aug 13 06:13:01 CDT 2002


Tom Dell'Aringa wrote:
> Listers,
>
> I'm working on a script that will allow me to highlight a row in a
> table with styles. In doing this, I'm grabbing the ID of the row I
> want to highlight. I then want to apply my CSS changes to the
> children of that row, the TD cells themselves.
>

Tom,

this might give you some ideas.
Works in PC/ IE5.5, Moz 1.0, Opera 6.0

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Changing bgColor</title>
<script language="Javascript" type="text/javascript">
<!--

function changeBgColor(hue){
   var TRobj = document.getElementById("therow");
   var TDobj = TRobj.getElementsByTagName("td");
   for (var i=0;i<TDobj.length;i++){
         TDobj.item(i).style.backgroundColor = '#' + hue;
     }
}

//-->
</script>
</head>
<body>

<table width="300" cellspacing="0" cellpadding="0" border="0">
<tr id="therow" onmouseover="changeBgColor('ff0000');"
onmouseout="changeBgColor('0000ff');"><td>blah</td>
                 <td>blah</td>
	            <td>blah</td>
	            <td>blah</td></tr></table>

</body>
</html>

hth,
--
=====================================================
Duncan O'Neill
"Smith The Reporter"
http://homepages.ihug.co.nz/~dbaxo/urban_legend.htm
=====================================================




More information about the thelist mailing list