Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing an element

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the button a child of the document?
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The button is an indirect child of the document. It is contained in table datacell inside table.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic