隐藏表格行(如果为空) [英] hide table rows if empty

查看:116
本文介绍了隐藏表格行(如果为空)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSP中有一个表格,当页面生成时,它可以是空的,我想知道是否有一种方法可以让我隐藏它们,但前提是它们没有实际的文本,下面是它们的外观

I have a table in my JSP that can, when the page is generated have empty and I want to know if there is a way for me to hide them only if they have no actual text in them, here is what they look like.

<TABLE border="1" style="empty-cells:hide;padding-left:4px">
<TR>
    <TD><s:property value="barfoo"/></TD>
    <TD align="center"><s:property value="foo"/></TD>
    <TD align="center"><s:property value="bar"/></TD>
    <TD align="center"><s:property value="foobar"/></TD>
</TR>
<TR>
    <TD><s:property value="barfoo"/></TD>
    <TD align="center"><s:property value="foo"/></TD>
    <TD align="center"><s:property value="bar"/></TD>
    <TD align="center"><s:property value="foobar"/></TD>
</TR>
<TR>
    <TD><s:property value="barfoo"/></TD>
    <TD align="center"><s:property value="foo"/></TD>
    <TD align="center"><s:property value="bar"/></TD>
    <TD align="center"><s:property value="foobar"/></TD>
</TR>
<TR>
    <TD><s:property value="barfoo"/></TD>
    <TD align="center"><s:property value="foo"/></TD>
    <TD align="center"><s:property value="bar"/></TD>
    <TD align="center"><s:property value="foobar"/></TD>
</TR>
</TABLE>

但是并不是所有的东西都会被填满,有时它们会基本回归空值只留下一个空白空间,我只想隐藏它们,只要他们要离开那个空白空间我可以使用一个简单的解决方案,在大多数浏览器上工作,以隐藏空白空间?

but the thing is not all of them will be filled out all the time, sometimes they will basically return null values just leaving behind an empty space, and I want to hide them only if they are going to leave that empty space any way I can use a simple solution that works on most browsers to hide that blank space?

推荐答案

您可以使用css :空的伪类

tagname:empty {
 display: none;
}

这个伪类样式空元素...

This pseudo-class styles empty elements...

在使用它之前,请确保它没有得到广泛的支持,最有可能的是IE会导致问题。

be sure before you use this as it is not widely supported yet, most probably IE will be causing problems

这篇关于隐藏表格行(如果为空)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆