表格事件,表格删除行

$th = $("<th>增加的列头</th>");
$col = $("<td>增加的列</td>");
$("#tab1>thead>tr").append($th);
$("#tab1>tbody>tr").append($col);

$("#tab1 tr :last-child").remove(); //移除最后一列
$("#tab1 tr :first-child").remove(); //移除第一列
$("#tab1 tr :nth-child(2)").remove(); //移除指定的列, 注:这种索引从1开始
$("#tab1 tr :not(:nth-child(1))").remove(); //移除第一列之外的列

$("#"+zwid).find("tr:last").remove(); //移除行
$("#"+zwid+" tr:last").after(obj.html); //添加行
$("#zbbg tr").eq(-2).after(td_html); //倒数第二行插入

$(line).parent().parent().closest("tr").index(); //根据表格中a标签的单击事件,获取当前行行号
$(line).parent().parent().closest("tr").remove(); //根据表格中a标签的单击事件,删除当前行

$(line).parent().parent().find('td').eq(0).text() //点击单元格编辑,获取该单元格的行第一个单元格的值

$("#zbbg tr").length; //获取表格行数
$(line).parent().prevAll().length + 1; //获取内容所在列
$(line).parent().parent().closest("tr").index(); //获取内容所在行

原文地址:https://www.cnblogs.com/chai-blogs/p/5254413.html