-
- function delete1(obj){
- var tr=obj.parentNode.parentNode;
- var tbody=tr.parentNode;
- tbody.removeChild(tr);
- }
- function delete2(obj){
- $(obj).parent().parent().parent()[0].removeChild($(obj).parent().parent()[0]);
- }
- function hide(obj){
- $(obj).parent().parent().hide();
- }
function delete1(obj){
var tr=obj.parentNode.parentNode;
var tbody=tr.parentNode;
tbody.removeChild(tr);
}
//使用Jquery 删除
function delete2(obj){
$(obj).parent().parent().parent()[0].removeChild($(obj).parent().parent()[0]);
}
//该方式只是将TR 元素隐藏
function hide(obj){
$(obj).parent().parent().hide();
}
HTML
- <table>
- <tbody>
- <tr>
- <td>xxx1</td>
- <td><span onclick="delete1(this)">删除</span></td>
- </tr>
- <tr>
- <td>xxx1</td>
- <td><span onclick="delete2(this)">删除</span></td>
- </tr>
- <tr>
- <td>xxx1</td>
- <td><span onclick="hide(this)">隐藏</span></td>
- </tr>
- </tbody>
- </table>