js动态增加行 删除行
生活随笔
收集整理的這篇文章主要介紹了
js动态增加行 删除行
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//動態增加行
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动态增加行 删除行的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sd卡数据恢复软件(手机数据恢复软件)
- 下一篇: springmvc ztree 实现权限