title: Remove dom element without knowing its parent?
body: <p>Is it possible to remove a dom element that has no parent other than the body tag? I know this would be easy with a framework like jquery, but I'm trying to stick to straight javascript.</p>
  
  <p>Here's the code I've found to do it otherwise:</p>
  
  <pre><code>function removeElement(parentDiv, childDiv){
       if (childDiv == parentDiv) {
            alert("The parent div cannot be removed.");
       }
       else if (document.getElementById(childDiv)) {     
            var child = document.getElementById(childDiv);
            var parent = document.getElementById(parentDiv);
            parent.removeChild(child);
       }
       else {
            alert("Child div has already been removed or does not exist.");
            return false;
       }
  }   
  </code></pre>
  
  <p>Thanks!</p>