Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用索引jQuery删除表行_Jquery - Fatal编程技术网

使用索引jQuery删除表行

使用索引jQuery删除表行,jquery,Jquery,我目前选择了一行,我想点击一个删除按钮,这将删除选中的行我已经有了行选择,只需要删除部分 我试过: $("#deleteBtn").click(function() { $(this).closest('tr').remove(); }); Html: 因为我没有看到你所有的html,所以我假设一个解决方案 为了选择一行,您可以将选定的类添加到该行中,并且可以从先前选定的类中删除此类类。因此,每次仅选择一行 在删除时,您只需删除包含所选类的行 $'splashTable tbody

我目前选择了一行,我想点击一个删除按钮,这将删除选中的行我已经有了行选择,只需要删除部分

我试过:

$("#deleteBtn").click(function() {
    $(this).closest('tr').remove();
});
Html:


因为我没有看到你所有的html,所以我假设一个解决方案

为了选择一行,您可以将选定的类添加到该行中,并且可以从先前选定的类中删除此类类。因此,每次仅选择一行

在删除时,您只需删除包含所选类的行

$'splashTable tbody tr'。单击,函数E{ $this.sides'.selected'.removeClass'selected'; $this.addClass'selected'; } $deleteBtn.clickfunction{ $'splashTable tbody tr.selected'。删除; }; .选定{ 背景颜色:黄色; } 删除所选行 第一 最后的 年龄 薪水 约翰1 弗里曼 36 $53,000 约翰2 弗里曼 36 $53,000
您的表中是否有多个id=deleteBtn?ID必须是唯一的,你应该使用一个类。非常感谢你的回答!工作完美
    <table id="splashTable" class="table table-fixed">
      <thead>
        <tr>
          <th class="col-xs-3">First</th>
          <th class="col-xs-3">Last</th>
          <th class="col-xs-6">Age</th>
          <th class="col-xs-6">Salary</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td class="col-xs-3">John</td>
          <td class="col-xs-3">Freeman</td>
          <td class="col-xs-6">36</td>
          <td class="col-xs-6">$53,000</td>
        </tr>