[thelist] DOM: accessing properties of "children" array - another solution

Tom Dell'Aringa pixelmech at yahoo.com
Tue Aug 13 11:06:01 CDT 2002


Thanks Duncan - I see the key here is being able to grab all the TD
elements using getElementsByTagName coming off the TR - great! I
didn't know you could do that. I may adjust my other script now, I
think this is better!

Tom

--- Duncan O'Neill <dbaxo at ihug.co.nz> wrote:
> 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,


=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com



More information about the thelist mailing list