【问题标题】:jQuery delete all rows except the hidden row in a table [closed]jQuery删除表中除隐藏行之外的所有行[关闭]
【发布时间】:2019-06-22 05:56:13
【问题描述】:

我在 jQuery 中搜索的一个简单解决方案,用于删除除表中隐藏行之外的所有表行。在这里,我已经尝试过基础级别(对不起,我是新手。)。

$("#example-datatable tbody tr:not(:hidden)").remove();

HTML 代码:

 <table id="example-datatable" class="table draggable table-striped table-bordered table-vcenter">
    <thead>
        <tr>
            <th>Account Name</th>
            <th>Meeting Date</th>
            <th>Start Time</th>
            <th>No Of Hours</th>
            <th>Project</th>
            <th>Status</th>
            <th>Created By</th>
            <th>Created On</th>
            <th>Modified By</th>
            <th class="text-center">Action</th>
        </tr>
    </thead>
    <tbody>
        <!-- Define the Template TR to Clone for rest of the Rows -->
        <tr style="display:none">
            <td>accountName</td>
            <td>meetingDate</td>
            <td>startTime</td>
            <td>no_of_hours</td>
            <td>projectName</td>
            <td>IsActive</td>
            <td>employeeDisplayName</td>
            <td>createdDate</td>
            <td>employeeDisplayName</td>
            <td class="text-center">
                <!--Buttons Binded here with primarykey ID-->
            </td>
        </tr>
    </tbody>
</table>

【问题讨论】:

  • 因为你的问题是目前写的,所以无法回答。
  • 请分享您的html,然后我们可以了解您想要做什么
  • 请建议我用其他方法来实现这一点。@connexo
  • @RohitVerma,我已经添加了我的html代码。请看一下。

标签: jquery html-table rows


【解决方案1】:

简单使用

$("#example-datatable tbody tr").not(":hidden").remove();

【讨论】:

    猜你喜欢
    • 2012-09-08
    • 2010-09-27
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    • 2020-12-15
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    相关资源
    最近更新 更多