I have a table wherein I add rows using javascript when a button is clicked. Here's my code:
$("#addToDisplay").click(function (event) {
$("#tblProducts").removeClass("hide");
var counter = 1;
event.preventDefault();
counter++;
var newRow = "<tr><td>" + $("#txtProducts").val() + "</td><td>" + ("#txtQty").val() "</td><td><input type='button' value='Remove' id='btnRemove' /></td></tr>";
$("#tblProducts").append(newRow);
});
My problem is since I add the remove button per row, hence including it inside the variable newRow, how do I add an onClick event for it so that if I clicked the remove button the corresponding rows would be removed?