I'm encountering an error when attempting to delete a table row: "Uncaught ReferenceError: remTable is not defined index.html:1:1". When I inspect index.html to identify the issue, I find this:
remTable(this)
This is my code:
const transactions = {
addTable(){
sModal.classList.remove();
let table = document.getElementById("data-table");
let len = table.rows.length;
let input = document.querySelectorAll("form input");
//inserting new row
let line = table.insertRow(len);
//inserting cells
let info = new Array(5);
info[0] = line.insertCell(0);
info[1] = line.insertCell(1);
info[2] = line.insertCell(2);
info[3] = line.insertCell(3);
info[4] = line.insertCell(4);
// n
info[0].innerHTML = len;
info[1].innerHTML = input[0].value;
info[2].innerHTML = input[1].value;
info[3].innerHTML = input[2].value;
info[4].innerHTML = `
<img src="assets/minus.svg" onclick="remTable(this)">
`;
},
remTable(r){
var i = r.parentNode.parentNode.rowIndex;
document.getElementById("data-table").deleteRow(i);
}
};
<tr>
<th>Example</th>
<th>Example</th>
<th>Example</th>
<th>Example</th>
<th>
<img src="assets/minus.svg" onclick="remTable(this)">
</th>
</tr>