试试把函数,都改成这样
deleteRow('mxh',1)  
改成
deleteRow('mxh',this.rowIndex)还有,最好不要这么写
document.all[tableID]  

document.getElementById(tableID)

解决方案 »

  1.   

    哦,是
    deleteRow('mxh'',this.parentNode.rowIndex)
      

  2.   

    <HTML>
        <HEAD>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <TITLE>New Document </TITLE>
            <script>
                function deleteRow(obj){
    while(obj){
    if(obj.tagName=="TR"){
    obj.parentNode.removeChild(obj);
    return;
    }
    obj = obj.parentNode;
    }

                }
            </script>
        </HEAD>
        <BODY>
            <table border=3 id=mxh>
                <tr>
                    <td>第1行</td>
                    <td width=30><input type=button onclick="deleteRow(this)" value="删除本行"></td>
                </tr>
                <tr>
                    <td>第2行</td>
                    <td><input type=button onclick="deleteRow(this)" value="删除本行"></td>
                </tr>
                <tr>
                    <td>第3行</td>
                    <td><input type=button onclick="deleteRow(this)" value="删除本行"></td>
                </tr>
                <tr>
                    <td>第4行</td>
                    <td><input type=button onclick="deleteRow(this)" value="删除本行"></td>
                </tr>
            </table>
        </BODY>
    </HTML>