I’m using the following code to clone a row in a table when the user clicks on the Add button:
$('.addButton').click(function () {
$('#quotesTable tbody>tr:last').clone(true).insertAfter('#quotesTable tbody>tr:last');
});
How can I clear the values of a the new row being added so that they are empty? For example if the user selects a listbox value, and enters text into a text box, then clicks on add, the same exact row is copied with the values selected and entered.
I need the newly added row to be empty.
Thanks
You could use the
findmethod to find all text inputs within the clone and clear their value using thevalmethod, passing an empty string as the argument:You may want to modify the
input[type='text'], selectselector if you have other controls you wish to clear as well.