File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Removing an element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Removing an element" Watch "Removing an element" New topic

Removing an element

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
How I remove an element from an HTML Page in javascript

I tried the following but it failed :

No Java Script error is returned but nothing happens.
Appreciate any help and advice.

Life is the biggest school
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Is the button a child of the document?

[Asking smart questions] [About Bear] [Books by Bear]
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
The button is an indirect child of the document. It is contained in table datacell inside table.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Bear was hinting at your problem without saying it. The element needs to be removed from the body or the parent element. You either need to do document.body.removeChild(btn) or btn.parentNode.removeChild(btn);
I agree. Here's the link:
subject: Removing an element
jQuery in Action, 3rd edition