How to delete a row from a dynamic generate table using jquery?
<p>My code creates dynamically a table using jquery. I want to add delete functionality to the table. So when clicking on delete image the row should be delete. But deleting works fine just when the table is static.
here id my code:</p>

<pre><code>createTable: function () {
    var lastRow = $('#TblInvoiceList tr:last');
    var newRow = $('&lt;tr&gt;');
    newRow.append($('&lt;td&gt;').text($('input.Name').val()), $('&lt;td&gt;').text($('input.GrossAmount').val()));
    newRow.append("&lt;td class='center'&gt;&lt;img class='ImgDelete' src='image/ButtonDelete.png' /&gt;&lt;/td&gt;");
    lastRow.before(newRow);}
</code></pre>

<p>and this is the delete function:</p>

<pre><code>$('#TblInvoiceList td img.ImgDelete').click(function () {
    alert("hi");
    $(this).parent().parent().remove();
});
</code></pre>
