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

Tom Dell'Aringa pixelmech at yahoo.com
Mon Aug 12 13:14:01 CDT 2002


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.

So far so good, but a bit of a snag. I'm using this function:

---------------------------

function walkChildren(objRef)
{
var obj = document.getElementById(objRef)
var i, group

group = obj.children
  for (i = 0; i < group.length; i++)
    {
      alert(group[i].id);
    }
}

---------------------------

I can pass my TR ID to this function. It grabs it fine, and "group"
becomes an array of each child under that TR, using the read-only
children method.

I can access individual properties of a child using:

group[i].property (you could read this child.1.property)

So in the above example, if all those TDs had IDs they would each pop
up in the alert.

I don't care about that, what I DO want to do is alter the styles.
(There is a style rule set for TD). I have tried:

group[i].style.color
group[i].color

to no avail. I cannot seem to find any reference in my books or
otherwise on what properties of the object are reachable via the
children property. I realize its a read-only property itself, but the
properties of the CHILD it references shouldn't be.

I CAN attach a method, and it will fire effectively, such as the
contains() method:

group[i].contains(document.getElementById('e'))

will return true for any td that has <em id='e'>blah</em> in it.

TIA

Tom

=====
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