1
我有一个按钮来克隆一行。我想找到一个输入,然后更改它的ID。如何在我的克隆行中找到特定元素并更改jquery中元素的ID
我的功能:
function cloneRow(tables, rows) {
var row = document.getElementById(rows); // find row to copy
var table = document.getElementById(tables); // find table to append to
var clone = row.cloneNode(true); // copy children too
clone.id = rows; // change id or other attributes/contents
table.appendChild(clone); // add new row to end of table
}
我行进行克隆:
<tr id="row">
<td width="5%"><button type="button" onclick="cloneRow('table', 'row')" class="btn btn-sm btn-info">Add</button></td>
<td><button type="button" onclick="removeRow2('table')" class="btn btn-sm btn-danger">Remove</button></td>
<td width="20%"><input type="text" required class="form-control" name="txtitemname[]" /></td>
<td width="30%"><input type="text" class="form-control" name="txtnote[]" placeholder="e.g. box of milk, bottles of water" /></td>
<td width="20%"><input type="text" class="form-control" style="background-color:#FFF" id="expiration-date" name="txtexpiration[]" /></td>
<td><input type="number" required min="1" value="1" class="form-control" name="txtquantity[]" /></td>
</tr>
我想,当它被克隆有效期限的ID更改为到期,日期1。
如何在每次克隆时增加它?如果我有到期日期2,则下一个将到期日期3。 –
已经完成。检查:) – Aswathy
谢谢先生:)。你节省了我的一天:) –