<tr>
<td>
<input type = "checkbox" name = "chk"/>
</td>
<td>
<select name = "foo">
<option value = "1">One</option>
<option value = "2">Two</option>
</select>
</td>
<td>
<select name = "bar">
<option value = "1">One</option>
<option value = "2">Two</option>
</select>
</td>
</tr>
<tr>
<td>
<input type = "checkbox" name = "chk"/>
</td>
<td>
<select name = "foo">
<option value = "1">One</option>
<option value = "2">Two</option>
</select>
</td>
<td>
<select name = "bar">
<option value = "1">One</option>
<option value = "2">Two</option>
</select>
</td>
</tr>
我想克隆带有选中复选框的选定项目的行。
我正在使用它,但它只是复制文本字段而不是所选项目。
lastRow = $('#dataTable tr').has('input:checked').html();
$('#dataTable tr:last').after('<tr>'+lastRow+'</tr>');
$('#dataTable tr:last').find('select').each(function()
{
var this_select=$(this);
this_select.val(this_select.closest('tr').prev().find('td:eq('+this_select.closest('td').index()+')').find('select').val());
});