Delete the entire table using Javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableData

Description

Delete the entire table using Javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
    function removeTable(id)
    {/*from w  w w  . j a va  2  s  .c  om*/
        var tbl = document.getElementById(id);
        if(tbl) 
           tbl.parentNode.removeChild(tbl);
    }

      </script> 
   </head> 
   <body> 
      <table id="toc" class="toc" border="1" summary="Contents"> 
         <tbody>
            <tr>
               <td>This table is going</td>
            </tr> 
         </tbody>
      </table> 
      <input type="button" onclick="removeTable('toc');" value="Remove!">  
   </body>
</html>

Related Tutorials