Js删除Table中的一行

<html>
<head>
    <title>title>
    <script type="text/javascript">
        function deleteCurrentRow(obj){
            var tr=obj.parentNode.parentNode;
            var tbody=tr.parentNode;
            tbody.removeChild(tr);
            //只剩行首时删除表格
            if(tbody.rows.length==1) {
                tbody.parentNode.removeChild(tbody);
            }
        }
    script>
head>
<body>
    <table cellspacing="0" rules="all" bordercolor="#CCCCCC" border="1" id="dgFlowList" style="border-color:#CCCCCC;border-width:1px;border-style:solid;width:98%;border-collapse:collapse;MARGIN: 5px 0px">
        <tr class="DataGrid_HeaderStyle" nowrap="nowrap" align="Center">
            <td>流程名称td><td>表单名称td><td>上传附件td><td>操作td>
        tr>
        <tr>
            <td style="width:35%;">请假单1td>
            <td style="width:35%;">请假单td>
            <td align="Center" style="width:10%;">不允许td>
            <td align="Center" style="width:20%;">
            <a href="javascript:;" onclick='{if(confirm("确定要删除【请假单1】这个流程吗?")) {deleteCurrentRow(this); }else {}}'>删除a>
            td>
        tr>
        <tr>
            <td style="width:35%;">请假单2td>
            <td style="width:35%;">请假单td>
            <td align="Center" style="width:10%;">不允许td>
            <td align="Center" style="width:20%;">
            <a href="javascript:;" onclick='{if(confirm("确定要删除【请假单2】这个流程吗?")) {deleteCurrentRow(this); }else {}}'>删除a>
            td>
        tr>
        <tr>
            <td style="width:35%;">请假单3td>
            <td style="width:35%;">请假单td>
            <td align="Center" style="width:10%;">不允许td>
            <td align="Center" style="width:20%;">
            <a href="javascript:;" onclick='{if(confirm("确定要删除【请假单3】这个流程吗?")) {deleteCurrentRow(this); }else {}}'>删除a>
            td>
        tr>
    table>
body>
html>

 

你可能感兴趣的:(Js删除Table中的一行)