Remove element from document - Javascript DOM

Javascript examples for DOM:Element remove

Description

Remove element from document

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(){//w  w  w . j  a v  a  2s .co  m
var btn = document.getElementById('btn');
btn.onclick = function () {
    document.getElementById('txt').remove();
    this.remove();
};
    }

      </script> 
   </head> 
   <body> 
      <p id="txt">Can i put it here?</p> 
      <input id="btn" type="submit" value="REMOVE THAT!!!">  
   </body>
</html>

Related Tutorials