Para hacer el código que mostraré me basé en la respuesta de esta pregunta Agregar filas a Tabla con JavaScript, DOM
ahora mostraré mi código:
este archivo se llama botones.js
function agregarFila(){
document.getElementById("tabla").insertRow(-1).innerHTML = '<td></td><td></td><td></td><td></td><td></td><td></td><td></td>';
}
function eliminarFila(){
var table = document.getElementById("tabla");
var rowCount = table.rows.length;
//console.log(rowCount);
if(rowCount <= 1)
alert('No se puede eliminar el encabezado');
else
table.deleteRow(rowCount -1);
}
redireccioné el archivo asi:
<script src="../bootstrap/js/botones.js"></script>
Este es un codigo html de prueba
<html>
<head>
<script src="../bootstrap/js/botones.js"></script>
</head>
<body>
<button type="button" class="btn btn-primary rounded-pill" onclick="eliminarFila()"> Eliminar fila</button>
<button type="button" class="btn btn-primary rounded-pill" onclick="agregarFila()"> Agregar fila</button>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"> <input type="text" value="akdk"> </th>
<td><input type="text" value="akdk"> </td>
<td><input type="text" value="akdk"> </td>
<td><input type="text" value="akdk"> </td>
</tr>
</tbody>
</table>
</body>
</html>