Remove the element from its parent with removeChild() method - Javascript DOM

Javascript examples for DOM:Element removeChild

Description

Remove the element from its parent with removeChild() method

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from ww w  . j a  va2  s  .  c  o  m
var parent = document.getElementById('parent');
parent.removeChild(parent.firstChild);
    }

      </script> 
   </head> 
   <body> 
      <div id="parent">
          I'm gone with the wind 
         <div id="child">
            I stay here
         </div> 
      </div>  
   </body>
</html>

Related Tutorials