I created an addRow function which allows me to add row to a table. After i Add the row, I wanted to create an option to delete the new row. Is there a way to recycle my function?
function addRow() {
var table = document.getElementById('dataTable');
var rowCount = table.rows.length;
var newRow= table.insertRow((1));
var c0 = newRow.insertCell
c0.innerHTML="<div ><img src='include/images/cross.png' alt='delete row' onclick='deleteRow(rowCount)'/></div>";
}
function deleteRow(row){
var elem = document.getElementById('tr'+row);
var old = (elem.parentNode).removeChild(elem);
}