• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can we remove a Node from a DOM tree?

 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we remove a Node from a DOM tree?
I know that one of the way is:-
lNode.getParentNode().removeChild(lNode);

In this method i need to check both lNode and lNode.getParentNode() not null before executing this method??
As if this method is called then refernce of ParentNode becomes null as it is detached from the parent node. Again calling the same method on that node can throw the nullpointerexception
Any other method which don't need the Parent Node reference
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!