How can I hide a TD tag using inline JavaScript or

2019-03-12 14:08发布

How can I hide a <td> tag using JavaScript or inline CSS?

8条回答
聊天终结者
2楼-- · 2019-03-12 14:26
.hide{

visibility: hidden

}

<td class="hide"/>

Edit- Just for you

The difference between display and visibility is this.

"display": has many properties or values, but the ones you're focused on are "none" and "block". "none" is like a hide value, and "block" is like show. If you use the "none" value you will totally hide what ever html tag you have applied this css style. If you use "block" you will see the html tag and it's content. very simple.

"visibility": has many values, but we want to know more about the "hidden" and "visible" values. "hidden" will work in the same way as the "block" value for display, but this will hide tag and it's content, but it will not hide the phisical space of that tag. For example, if you have a couple of text lines, then and image (picture) and then a table with three columns and two rows with icons and text. Now if you apply the visibility css with the hidden value to the image, the image will disappear but the space the image was using will remaing in it's place, in other words, you will end with a big space (hole) between the text and the table. Now if you use the "visible" value your target tag and it's elements will be visible again.

查看更多
放荡不羁爱自由
3楼-- · 2019-03-12 14:27

What do you expect to happen in it's place? The table can't reflow to fill the space left - this seems like a recipe for buggy browser responses.

Think about hiding the contents of the td, not the td itself.

查看更多
老娘就宠你
4楼-- · 2019-03-12 14:28

You can simply hide the <td> tag content by just including a style attribute: style = "display:none"

For e.g

<td style = "display:none" >
<p> I'm invisible </p>
</td>
查看更多
时光不老,我们不散
5楼-- · 2019-03-12 14:35

If you have more than this in javascript consider some javascript library, e.g. jquery which takes away a little speed, but gives you more readable code.

Your question's code via jquery:

$("td").hide();

Of course there are other javascript libraries out there, as this comparison on wikipedia shows.

查看更多
相关推荐>>
6楼-- · 2019-03-12 14:36

Everything is possible (or almost) with css, just use:

display: none; //to hide

display: table-cell //to show
查看更多
甜甜的少女心
7楼-- · 2019-03-12 14:36

We can hide the content inside a by using the following inline css:

<div style="visibility:hidden"></div>

for example:

<td><div style="visibility:hidden">Your Content Goes Here:</div></td>
查看更多
登录 后发表回答