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>