我复制Tr的id为clone并递增它:我希望TR内的Ids增加,例如:One1,One2,One3等 增量Id一二三/ 例如:One1,One2等也适用于其他人
我的HTML:
<table>
<thead>
<tr>
<th>Input</th>
<th>Checkbox 1</th>
<th>Checkbox 2</th>
<th>Add More</th>
</tr>
</thead>
<tbody>
<tr id="clone" class="clone">
<td class="form" data-label="Name"> <input id="One" type="text"> </td>
<td data-label="Add"><input id="Two" type="checkbox"></td>
<td data-label="Edit"><input id="Three" type="checkbox"></td>
<td data-label="Edit"><button class="addmore" onclick="duplicate();">Add More</button></td>
</tr>
</tbody>
</table>
我的JS:
function duplicate() {
var i = 0;
var original = document.getElementById('clone');
var count = 1;
if (count < 20) {
var clone = original.cloneNode(true); // "deep" clone
clone.id = "clone" + ++i; // there can only be one element with an ID
original.parentNode.appendChild(clone);
count++;
var $address = $('.clone', '#One');
address.attr('id', 'One' + rowNum);
} else {
}
}
问题:
我想增加内在的ID,如何增加它?