RemoveChild

E

Enzo

Hi,

I have a <div> created dynamically with 'appendchild',
inside it a form. When I press the 'esc' key, inside
the <div>, I need to remove them and return to the
parent page.

Using parent.removeChild(div) does not work?!?!

Any idea?

Thanks,

Enzo
 
R

Richard Cornford

Danny said:
Well, from the child, use this.parentElement.removeChild(this);

There is little point in mixing the Microsoft proprietary DOM with the
W3C standard DOM. If the - parentElement - property form the Microsoft
DOM is to be used it would be more reasonable to employ its -
removeNode - method to remove the child, and never expect the results to
work with standards compliant browsers. Otherwise the W3C DOM standard -
parentNode - property is the sensible source of a reference to the
containing node, i.e.:-

nodeRef.parentNode.removeChild(nodeRef);
Please do not top-post on comp.lang.javascript.

Richard.
 
E

Enzo

The div is created in the main page,
and seems to be inaccessible from
the second page (inside the div).

Enzo
 
M

Michael Winter

The div is created in the main page, and seems to be inaccessible
from the second page (inside the div).

That would explain the use of 'parent', but not 'div'. Does the DIV
element have a 'div' id attribute value? If so, don't take that
approach. See <URL:http://www.jibbering.com/faq/#FAQ4_41>.

Mike


Please quote relevant text when replying.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top