<div id="parent_${id}"></div>
var tableHead = "<table id='ftTableID'><thead><th class='th4'>First Name</th><th class='th5'>Last Name</th><th>Action</th></thead>")}"+"";
$('#parent_itemId').prepend(tableHead);
$('#ftTableID').append("</table>");
在此之后追加新tr
到div
:我们是否可以得到布尔值(true或false)是否删除的tr是否在div内?
var $newElem = $("<tr>").html(elem).attr({'id': id + num1, 'no': num1});
// creates the "Remove" button
var $removeButton = $('<input type="button" class="deleteButton" value="Delete" /></tr>').appendTo($newElem);
$removeButton.attr({
id: 'remove_' + id,
value: removeBtnLabel ? removeBtnLabel : 'Remove',
disabled: 'disabled'
});
// binds handler to the 'click' JS event of the "Remove" button
$removeButton.click(function() {
removeItem(id, num1, min);
});
追加tr
到div
:
$('#parent_' + id).append($newElem);
首先tr
将在上述div id
被追加与ADD和取消旁边的按钮 。虽然我们点击ADD按钮,下一步tr
将加入ADD和取消旁边的按钮。 ADD按钮将被省略,从第一个tr
只剩下取消按钮在第一个tr
等等。现在当我按CANCELL按钮时,我需要知道删除的行(tr
)是否是最后一行?
现在,当调用removeItem()函数时,我想查找tr
是否是最后的tr
?
'$( 'TR:去年')'试试这个选择器':last'或方法'.last()' – guradio
每个'tr'是否都有自己的取消按钮,它会删除那个'tr'? – wmash
是的,每个tr都有自己的取消按钮,可以删除相应的tr @wmash –