Lets say i have a table:
<table>
<tr></tr>
</table>
$(function(){
$('#btn').click(function(){
$('table').append('<tr><input class="remove" value="remove"></tr>');
});
$('.remove').on('click', function(){
$(this).parent().remove();
});
});
Is there any way to bind a custom event handler that triggers whenever a row is added or removed, using jQuery?
Thanks
Yes, you can bind custom event.
$('#table_id').bind('rowAddOrRemove', function(event){
//do what you want.
});
And when you add or remove a row, you should trigger the event.
$('#table_id').trigger('rowAddOrRemove');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With