I want to effectively simulate pressing the "delete" button and remove the elements. I can do it with "deleteRow", but I want to specifically target the button "delete" to do this in the DOM specifically. This is about automating the press via the DOM. Table example is from W3*.
HTML
<table id="mytab1">
<tr>
<td>Row 1</td>
<td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
</tr>
<tr>
<td>Row 2</td>
<td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
</tr>
<tr>
<td>Row 3</td>
<td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
</tr>
</table>
Javscript
for(var i = 0; i < 3; i++){
var x = document.getElementById("mytab1").deleteRow('tr');
}
Thank you in advance.