删除table中的TR

来源:互联网 发布:微信打不开爱淘宝 编辑:程序博客网 时间:2024/05/26 12:06

function removeRow(r){

     var root = r.parentNode;
    root.removeChild(r);


}

 

 

 

 

<table id="t" cellpadding="1" cellspacing="1">
  <tr id=a1>
   <td>
    1111
   </td>
   <td>
    <input type="button" value="remove" onclick="removeRow(this.parentNode.parentNode)"/>
   </td>
  </tr>
  <tr id=a2>
   <td>
    222222222
   </td>
   <td>
    <input type="button" value="remove" onclick="removeRow(this.parentNode.parentNode)"/>
   
   </td>
  </tr>

  <tr id=a3>
   <td>
    3333333333
   </td>
   <td>
    <input type="button" value="remove" onclick="removeRow(this.parentNode.parentNode)"/>
   
   </td>
  </tr>
  </table>

 

原创粉丝点击