Answers for "javascript remove clicked table row from table"

0

javascript remove clicked table row from table

<script>
    function RemoveRow(o) {
     //no clue what to put here?
     var p=o.parentNode.parentNode;
         p.parentNode.removeChild(p);
    }
</script>

<table>
   <tr>
       <td><input type="button" value="Delete Row" onclick="RemoveRow(this)"></td>
   </tr>
   <tr>
       <td><input type="button" value="Delete Row" onclick="RemoveRow(this)"></td>
   </tr>
   <tr>
       <td><input type="button" value="Delete Row" onclick="RemoveRow(this)"></td>
   </tr>
</table>
Posted by: Guest on July-07-2021
0

javascript remove clicked table row from table

<script>
  function RemoveRow() {
      // event.target will be the input element.
      var td = event.target.parentNode; 
      var tr = td.parentNode; // the row to be removed
      tr.parentNode.removeChild(tr);
</script>

<table>
   <tr>
       <td><input type="button" value="Delete Row" onclick="RemoveRow()"></td>
   </tr>
   <tr>
       <td><input type="button" value="Delete Row" onclick="RemoveRow()"></td>
   </tr>
   <tr>
       <td><input type="button" value="Delete Row" onclick="RemoveRow()"></td>
   </tr>
</table>
Posted by: Guest on July-07-2021

Code answers related to "javascript remove clicked table row from table"

Code answers related to "Javascript"

Browse Popular Code Answers by Language