Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

brad

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

javascript - dom method for removing nodes

You can remove existing nodes as well as add new ones. The removeChild method allows any node to remove one of its child nodes. Simply pass a reference to the node you wish to remove. Any text or elements within the node being removed will be removed along with it.

   1  
   2  <script type="text/javascript">
   3  
   4  function removeBElm(){
   5  
   6      var para = document.getElementById("example2");
   7  
   8      var boldElm = document.getElementById("example2B");
   9  
  10      var removed = para.removeChild(boldElm);
  11  
  12  }
  13  </script>


   1  
   2  <p id="example2"><a href="#" onclick="removeBElm(); return false;">Click this link</a> to see the above script in action.</p>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS