[Javascript] javascript DOM doubt

Jens Brueckmann jens.brueckmann at gmail.com
Fri Aug 25 05:01:00 CDT 2006


Hi Suresh,

> suppose i am already having a parent node and the child node.i want to
> append a another child node below the already available child node.
>
>
>          <div id='iedisplayarea'>     //parent node
>                      |
>                      |
>              <img id='ashow'>              //child node of iedisplay area
>                      |
>                      |
>              <img id='ashow1'>            //child node of ashow

This tree is the root of your problem. The content model of the IMG
element is empty. Thus, IMG can not have any children.
In your tree, "ashow1" can not be a child of "ashow", it is a sibling.
The IMG element you want to append becomes a child of the parent
element, which is "iedisplayarea".

Change the following line of your code accordingly to:

  var x = document.getElementById('iedisplayarea');

Cheers,

jens

-- 
Jens Brueckmann
http://www.yalf.de



More information about the Javascript mailing list