jquery - 使用 JQuery 从 HTML 表格中删除空白行

标签 jquery html .net html-table asp.net-mvc-2

我有一个 HTML 表格:

<table id="indicationResults" class="resultsGrid" cellpadding="2" cellspacing="0" >

表格中的某些单元格仅包含取决于特定权限的字符串。例如,如果用户具有特定权限,这里有一行仅在每个单元格中放置标签和数据:

<tr>
    <td id="DV01Label" class="resultsCell">
        <%= CustomHelpers.StringWithPermission("DV01", new string[] { PERMISSIONS.hasALM })%>
    </td>
    <td id="DV01Value" class="alignRight">
        <%= CustomHelpers.StringWithPermission(Model.Results.DV01.ToString(Chatham.Web.Data.Constants.Format.CurrencyCentsIncludedFormatString), new string[] { PERMISSIONS.hasALM })%>
    </td>
    <td id="DV01Fixed" class="alignRight">
        <%= CustomHelpers.StringWithPermission(Model.Results.FixedComponent().DV01.ToString(Chatham.Web.Data.Constants.Format.CurrencyCentsIncludedFormatString), new string[] {PERMISSIONS.hasALM})%>
    </td>
    <td id="DV01Floating" class="alignRight">
        <%= CustomHelpers.StringWithPermission(Model.Results.FloatingComponent().DV01.ToString(Chatham.Web.Data.Constants.Format.CurrencyCentsIncludedFormatString), new string[] { PERMISSIONS.hasALM })%>
    </td>
</tr>

在使用 JQuery 加载页面后,我如何返回并删除此 SPECIFIC 表中的所有完全空行,而不是看到一个很小的空行,它只是不存在。

最佳答案

使用 jQuery:

$('#indicationResults tr').each(function () {
     if (!$.trim($(this).text())) $(this).remove();
});

虽然如果您可以将您的 asp 修改为仅在用户具有正确权限时输出行会更好;)

关于jquery - 使用 JQuery 从 HTML 表格中删除空白行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4760583/

相关文章:

javascript - 带有 Accordion 标题的 Jquery 图片库

javascript - 无法检查一个正方形是否为空 tictactoe 游戏 jquery

javascript - 使用 javascript 查询额外的 Rails 数据

php - 处理未知大小的 PHP 数组

c# - Azure 和本地 TCP 连接数有很大不同

c# - 将值从 View 传递到 Controller,我缺少什么?

c# - 使用 Oracle.ManagedAccess 使用存储过程执行内联语句

javascript - 将模板添加到 div 内的 img 前面

javascript - 取消选中复选框并修改总计 - JS

javascript - HTML 单选按钮崩溃 JavaScript 表单功能