【问题标题】:How to delete rows with rowspan jquery如何使用rowspan jquery删除行
【发布时间】:2013-11-15 17:48:51
【问题描述】:
<table id="personal" border="1">
  <tr>
    <td>Name</td>
    <td>Address</td>
    <td rowspan="2" class="remove">Remove</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>Address</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>Address</td>
    <td rowspan="2" class="remove">Remove</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>Address</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>Address</td>
    <td rowspan="2" class="remove">Remove</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>Address</td>
  </tr>
</table>

$('#personal tr .remove').click(function(){
$(this).parent().remove();
})

我想删除受行跨度影响的 2 行。有可能的?如果是怎么办?现在它只删除一行。

小提琴:http://jsfiddle.net/awanan/j3fNK/

【问题讨论】:

    标签: jquery row html-table


    【解决方案1】:

    最简单的方法:

    $('#personal tr .remove').click(function(){
       $(this).parent().next().remove();
       $(this).parent().remove();
    })
    

    【讨论】:

      【解决方案2】:

      $(this).parent().next().remove(); 放在$(this).parent().remove(); 之前

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-29
        • 2017-04-29
        • 1970-01-01
        • 1970-01-01
        • 2023-03-26
        • 1970-01-01
        • 2012-12-18
        • 1970-01-01
        相关资源
        最近更新 更多