//动态增加行
function addRow(tab){
var title = "";
var table = document.getElementById(tab);
var newRow = table.insertRow();//
var newCell = newRow.insertCell();
if(tab=="projectTab"){
title = $("#proTitle").val();
newCell.innerHTML="<input type='text' value="+title+" style='border-top:0px;border-left:0px;border-bottom:0px;border-right:0px;width:70px;' /><textarea style='width:600px;height:120px;vertical-align:top;'></textarea> <a href='javascript:void(0);' οnclick=\"deleteRow(this,'projectTab')\">删除</a>";
}else if(tab=="companyTab"){
title = $("#comTitle").val();
newCell.innerHTML="<input type='text' value="+title+" style='border-top:0px;border-left:0px;border-bottom:0px;border-right:0px;width:70px;' /><textarea style='width:600px;height:120px;vertical-align:top;'></textarea> <a href='javascript:void(0);' οnclick=\"deleteRow(this,'companyTab')\">删除</a>";
}else{
title = $("#riskTitle").val();
newCell.innerHTML="<input type='text' value="+title+" style='border-top:0px;border-left:0px;border-bottom:0px;border-right:0px;width:70px;' /><textarea style='width:600px;height:120px;vertical-align:top;'></textarea> <a href='javascript:void(0);' οnclick=\"deleteRow(this,'riskTab')\">删除</a>";
}
}
//动态删除行
function deleteRow(obj,tab){
var tr = obj.parentNode.parentNode;
var tbody = tr.parentNode;
tbody.removeChild(tr);
}
js动态增加行 删除行
最新推荐文章于 2020-11-06 04:12:32 发布