My project is C# MVC.
I have a table whose last row contains a dropdownlist with an 'Add' button. On clicking the 'Add' button, a row is added to the table via JQuery. This works fine.
Part of the row that is added is a 'Remove' button that I want to use to delete the row.
Strange thing is, the "Remove" button's click event is not being picked up by JQuery. It is exactly the same as the "Add" button, just with a different ID. Anyone know why this would be so? Code below.
$('#AddBuyCondition').click(function () {
alert("abc");
var conditionID = +$("#BuyConditionList").val();
var conditionText = $("#BuyConditionList").find('option:selected').text();
$('#BCDropDownRow').before('<tr><td>' + conditionText + '</td><td><button id="RemoveBuyCondition" type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-minus"></span></button></td></tr>');
});
$('#RemoveBuyCondition').click(function () {
alert("rbc");
});