On March 10, 2000 Jason Harrop wrote:
>
> Hello; i was hoping someone could help me out with an
> example of how to use replaceChild.
>
> Suppose my node had 5 children, and i wanted to replace the
> third child.
>
> I have tried making a NodeList with getChildNodes, and then using
> replaceChild, where oldChild is the third item in the node list. But
> this seems to give DOM Exception 005 Wrong document.
>
> What is the easiest way to do this please?
Try something like the following to access a particular child node:
for(i = 0, child = node.getFirstChild(); !child.isNull(); child =
child.getNextSibling(), i++) {
if(2 == i) {
//this is the third child
//do something
break;
}
}
--
Anand R
> jason harrop