I have a table with an Add button on the end. When you click this button I want a new table row to be created underneath the current one. I also want the input fields on thi
Try this code, I used the following code for cloning and removing the cloned element, i have also used new class (newClass) which can be added automatically with the newly cloned html
for cloning..
$(".tr_clone_add").live('click', function() {
var $tr = $(this).closest('.tr_clone');
var newClass='newClass';
var $clone = $tr.clone().addClass(newClass);
$clone.find(':text').val('');
$tr.after($clone);
});
for removing the clone element.
$(".tr_clone_remove").live('click', function() { //Once remove button is clicked
$(".newClass:last").remove(); //Remove field html
x--; //Decrement field counter
});
html is as followinng