richarddunnebsc
Active Coder
I have the following code that adds a new row to a table, then replaces an add button with a delete button
One, problem, why I click a delete (X) button, nothing happens. After inspecting the code, the added delete button doesn't have a onclick() function. Hence nothing happens.
Any ideas what the problem is/might be? Appreciate any help.
JavaScript:
var table = $('#Table');
var lastRow = table.find('tr:last');
var clone = lastRow.clone();
table.append(clone);
var button = document.createElement("input");
button.type = "button";
button.value = "X";
button.name ="DeleteRow";
button.style.width = "50%";
button.addEventListener('click',function(){
DeleteRow(this);
})
clone.find('td:first').empty();
clone.find('td:first').append(button);
One, problem, why I click a delete (X) button, nothing happens. After inspecting the code, the added delete button doesn't have a onclick() function. Hence nothing happens.
Any ideas what the problem is/might be? Appreciate any help.