tags:

views:

35

answers:

3

Possible Duplicate:
How can I clone a row in a table without cloning the values of the input elements inside it?

i am trying to add a row to a table.i found that we can use clone . my table has two text boxes in it in two different tr's .cloning the last row is also duplicating the values in my textbox's which i don't want ?Any ideas ???

my code

$("#table-1 tr:last").clone();
+1  A: 

may be somthing like this

 $("#table-1 tr:last").clone().find('input[type=text]').val('');
Ninja Dude
+1  A: 

If you want to add a row with the inputs, but not the values, you could do something like what you have, and just clear the values:

var row = $("#table-1 tr:last").clone();
row.find( 'input' ).each( function(){
    $( this ).val( '' )
});
row.appendTo( "#table-1" )
hookedonwinter
I'm assuming, with my answer, that your row has inputs.. If you could post the html of the row, we could help better.
hookedonwinter
A: 

Just clear the input fields after cloning :

var row = $("#table-1 tr:last").clone().find(':input').val('').end();

// then add the row at the end of the table
$("#table-1").append(row);
Yanick Rochon