Remove parent element with element.parentNode.remove() - Javascript DOM

Javascript examples for DOM:Element parentNode

Description

Remove parent element with element.parentNode.remove()

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <table id="test"> 
         <tbody>
            <tr> 
               <td>one</td>
               <td>two</td>
               <td id="test" onclick="removerow(this);">remove</td> 
            </tr> 
         </tbody>
      </table> 
      <script type="text/javascript">
function removerow(e) {//from w w w . j a v  a 2  s  .c o m
    e.parentNode.remove();
}

      </script>  
   </body>
</html>

Related Tutorials