There is something about the table delete functionality that prevents the event triggers from working the same way they do with the click on the add, I'm not certain what it is. However, there is a fairly simple way we can get around this, we'll just run the code anytime the table is clicked at all. That means we can use the same event trigger for both adding and deleting.
Additionally, a couple tips:
- If you have an event trigger that is just calling a function, you can just put the function into the code instead of doing a function() { //code } command. Instead of: $('.tablejq').on('click', '.form-del-field', function () { rowcount(); }); you can do $('.tablejq').on('click', '.form-del-field', rowcount});
- JQuery has a steamlined way to handle click event, you'll see that in the updated code I shared below.
- LFAnswers has a functionality for posting code in posts or comments that makes them much easier to read (see the "{...} code" button).
All of that together is combined, and here's some streamlined code that should work for you:
$(document).ready(function() {
rowcount();
$('.tablejq').click(rowcount);
function rowcount() {
$('.totalInTable input').val($('.propCount').val());
}
});