jinesh jinesh - 1 year ago 80
jQuery Question

jQuery Copy dynamically added table row values into next row

<table>
<tr>
<td>Name</td>
<td>Location</td>
<td>Date</td>
<td>Valid</td>
<td>Add</td>
</tr>
<tr class="tr_clone">
<td>
<input type="text" >
</td>
<td>
<input type="text" >
</td>
<td>
<input type="text" class="datepicker">
</td>
<td>
<input type="checkbox" >
</td>
<td>
<input type="button" name="add" value="Add">
</td>
</tr>
</table>


i need to insert only the values from the table row( not include the input filed) into next row in the table.

Please give your valuable suggestions

Answer Source

Try this code:

var new_row = '<tr>';
$('table .tr_clone td').each(function(){
    new_row += '<td>'+$(this).find('input').val()+'</td>';
});
new_row += '</tr>';
$('table').append(new_row);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download