Sounds hard, but very simple.
Say I have a table on a page and a button to add rows to that table. On that button, I have added an ONCLICK to go to the function below.
Below, I gave my table a CLASS name because .Net screws up the ID — and I am able to call that when the button is clicked.
Here the .append function adds after the last element — THIS COULD BE PROBLEM FOR YOU if you have a TBODY. There are workarounds but I am not going to discuss those at this time.
function AddCustomSetting() { $('.cusSettingsTable').append("<tr><td onclick='RemoveRow(this);'>Remove</a></td><td><input type='textbox' /></td><td>Test Me</td><td></td></tr>"); }
That is all it would take to add a new Row to a table… now what if we want to remove it? Well notice in that append statement that I added another onclick function to remove the row and sent the TD (via this) element with the call. Here is that function:
function RemoveRow(c) { $(c).parent().remove(); }
And that is it! JQuery strikes again!
ciao!
t

