使用 JQuery 从 HTML 表中删除空白行
我有一个 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 加载页面后,如何返回并删除此特定表中所有完全空的行,因此而不是看到一个小小的空行,它只是不存在。
I have an HTML table:
<table id="indicationResults" class="resultsGrid" cellpadding="2" cellspacing="0" >
Some of the cells in the table only contain strings depending on specific permissions. For example, here is one row that only puts a label and data in each cell if the user has a specific permission:
<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>
How do I go back through and delete and all completely empty rows in this SPECIFIC table after the page loads using JQuery, so instead of seeing a tiny little empty row, it's just not there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jQuery:
尽管如果您可以将您的 asp 修改为仅在用户具有正确权限时输出行,那就更好了;)
With jQuery:
Although it would be much better if you could modify your asp to only output rows when the user has the right permissions ;)
您应该编写一个合适的 HTML 帮助器。与 Web 表单相反,MVC 使您可以完全控制生成的 HTML,并且完全不能原谅使用 javascript 来修复损坏的 HTML。
所以:
然后:
You should write a proper HTML helper. Contrary to web forms, MVC gives you full control over the generated HTML and is totally inexcusable to use javascript to fix broken HTML.
So:
and then: