当前位置: 首页 > 工具软件 > Tablecloth.js > 使用案例 >

js - table操作

姬俊驰
2023-12-01
function addCol() {
   $th = $( "<th>增加的列头</th>" );
   $col = $( "<td>增加的列</td>" );
   $( "#tab1>thead>tr" ).append($th);
   $( "#tab1>tbody>tr" ).append($col);
}
function delCol() {
   //移除最后一列
   $( "#tab1 tr :last-child" ).remove();
   //移除第一列
   //$("#tab1 tr :first-child").remove();
   //移除指定的列, 注:这种索引从1开始
   //$("#tab1 tr :nth-child(2)").remove();
   //移除第一列之外的列
   //$("#tab1 tr :not(:nth-child(1))").remove();
}
 类似资料: