<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());
});
答案 0 :(得分:3)