aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Removing an element" Watch "Removing an element" New topic
Author

Removing an element

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Hi,
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.


SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Is the button a child of the document?


[Asking smart questions] [Bear's FrontMan] [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
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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);
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Removing an element