如何获取html java脚本中添加/删除表的最后一行的所有文本框id ...
我想从html表和数据库中删除我的最后一行..所以如何获取最后一行的id ... 请帮我处理代码片段?
function remvmain(i) {
var table = document.getElementById("1.1.2");
$('#1.1.2 tr:last').find('input:text').each(function(){
alert($(this).attr('id') );
});
var rows = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr').length;
alert(rows-1);
i=i-1;
var n=i*5;
if( i > 1 ) {
rows = rows - 1;
var row = table.deleteRow(rows);
rows = rows - 1;
row = table.rows[rows];
var m=n/5;
var type=document.getElementById("fullname"+n);
if(type == null){
var x = row.insertCell(4);
x.innerHTML = "<a href='javascript:void(0);' id='addNew' onclick='addmain("+m+")'><img style='padding-left: 12px;' src='./images/Plus.png' /></a> <a href='javascript:void(0);' id='remNew' onclick='remvmain("+m+")'><img style='padding-left: 12px;' src='./images/close.png'/></a>";
} else {
var val = parseInt(document.getElementById("fullname"+n).value);
var member = document.getElementById("families").value;
var last2 = member.slice(-2);
var secondary = parseInt(document.getElementById("family"));
rows=rows-val-1;
row = table.rows[rows];
var x = row.insertCell(4);
flag=1;
x.innerHTML = "<a href='javascript:void(0);' id='addNew' onclick='addmain("+m+")'><img style='padding-left: 12px;' src='./images/Plus.png' /></a> <a href='javascript:void(0);' id='remNew' onclick='remvmain("+m+")'><img style='padding-left: 12px;' 'src='./images/close.png' /></a>";
}
} else {
rows = rows - 1;
var row = table.deleteRow(rows);
rows = rows - 1;
row = table.rows[rows];
var x = row.insertCell(4);
x.innerHTML="<a href='javascript:void(0);' id='addNew' onclick='addmain("+i+")'><img style='padding-left: 12px;' src='./images/Plus.png'/></a>";
}
document.getElementById("maincount").value=i;
return false;
}