如果需要选择进行删除的话,在<tr id='0141'>
下面加一个checkbox,然后使用下面的代码即可function delRow(obj)
{
var myTable = document.getElementById("0141");
var bod = myTable.tBodies[0] ; if (bod.rows.length == 0) return;
    // use childNodes property to find checked rows and remove them
 for (var x = bod.rows.length-1; x >= 0; x-- )
   if (bod.rows[x].cells[0].childNodes[0].checked)
    bod.deleteRow(x); 
}如果不选择,就全部删除的话,把上面的代码中的if (bod.rows[x].cells[0].childNodes[0].checked)去掉即可

解决方案 »

  1.   

    同上<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD>
    <body >
    <table id=t1>
    <tr>
    <td>a</td><td>b</td>
    </tr>
    <tr>
    <td>c</td><td>d</td>
    </tr>
    </talbe>
    <input type=button value="delete row" onclick="if(t1.rows.length >= 1) t1.deleteRow(0)">
    <input type=button value="insert row" onclick="var oRow = t1.insertRow(0);oRow.insertCell().innerHTML = '<td>k</td>';oRow.insertCell().innerHTML='<td>l</td>'"></body></HTML>
      

  2.   

    <table>
    <tr id='0141' onclick="this.style.display='none'">
    <td class=td width="10%" bgcolor="#CCCC99" nowrap><a href="javascript:insertsmilie0('0141','0');">0141</td>
    <td class=td width="10%" bgcolor="#E0c090" nowrap>yyyyyyyy</a></td>
    <td class=td width="10%" bgcolor="#E2D1A3" nowrap>教务处</td>
    </tr>
    <tr id='0142' onclick="this.style.display='none'">
    <td class=td width="10%" bgcolor="#CCCC99" nowrap><a href="javascript:insertsmilie0('0141','0');">0141</td>
    <td class=td width="10%" bgcolor="#E0c090" nowrap>yyyyyyyy</a></td>
    <td class=td width="10%" bgcolor="#E2D1A3" nowrap>教务处</td>
    </tr>
    </table>
      

  3.   

    <table>
    <tr id='0141' onclick="this.style.display='none'">
    <td class=td width="10%" bgcolor="#CCCC99" nowrap><a href="javascript:insertsmilie0('0141','0');">0141</td>
    <td class=td width="10%" bgcolor="#E0c090" nowrap>yyyyyyyy</a></td>
    <td class=td width="10%" bgcolor="#E2D1A3" nowrap>教务处</td>
    </tr>
    <tr id='0142' onclick="this.style.display='none'">
    <td class=td width="10%" bgcolor="#CCCC99" nowrap><a href="javascript:insertsmilie0('0141','0');">0141</td>
    <td class=td width="10%" bgcolor="#E0c090" nowrap>yyyyyyyy</a></td>
    <td class=td width="10%" bgcolor="#E2D1A3" nowrap>教务处</td>
    </tr>
    </table>