我有一个表,其中有很多列。
使用我当前的代码,我克隆了最后一行的所有内容。
$("#tTable tbody tr:last").clone(true).insertBefore($("#tTable tbody tr:last")).show();
如何修改此代码以便复制除元素之外的所有内容:lList、cSpan 及其子元素?
<table id="tTable">
<tbody>
<tr>
<td>
<select id="lList" class="listClass">
<option value="0">(select here)</option>
<span class="cSpan"><input title="custom" class="custom-combobox-input ui-autocomplete-input" autocomplete="off">
<a class="comboboxButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only custom-combobox-toggle" tabindex="-1" role="button"><span class="ui-button-text"></span></a>
<div id="labelDiv"><label id="displayComboBoxText"></label>/div>
<input id="ID" name="ID" type="hidden" value="">
</td>
</tr>
</tbody>
</table>
最佳答案
使用查找选择器查找第一个的td
,然后将其删除
var row=$("#tTable tbody tr:last").clone(true).find("td:first").remove().end();
关于jquery - 如何部分克隆行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24902614/