javascript remove clicked table row from table

Solutions on MaxInterview for javascript remove clicked table row from table by the best coders in the world

showing results for - "javascript remove clicked table row from table"
Frida
21 Sep 2020
1<script>
2  function RemoveRow() {
3      // event.target will be the input element.
4      var td = event.target.parentNode; 
5      var tr = td.parentNode; // the row to be removed
6      tr.parentNode.removeChild(tr);
7</script>
8
9<table>
10   <tr>
11       <td><input type="button" value="Delete Row" onclick="RemoveRow()"></td>
12   </tr>
13   <tr>
14       <td><input type="button" value="Delete Row" onclick="RemoveRow()"></td>
15   </tr>
16   <tr>
17       <td><input type="button" value="Delete Row" onclick="RemoveRow()"></td>
18   </tr>
19</table>
Rian
01 Mar 2016
1<script>
2    function RemoveRow(o) {
3     //no clue what to put here?
4     var p=o.parentNode.parentNode;
5         p.parentNode.removeChild(p);
6    }
7</script>
8
9<table>
10   <tr>
11       <td><input type="button" value="Delete Row" onclick="RemoveRow(this)"></td>
12   </tr>
13   <tr>
14       <td><input type="button" value="Delete Row" onclick="RemoveRow(this)"></td>
15   </tr>
16   <tr>
17       <td><input type="button" value="Delete Row" onclick="RemoveRow(this)"></td>
18   </tr>
19</table>
20