如何阻止损坏的图像显示 [英] How to stop broken images showing

查看:119
本文介绍了如何阻止损坏的图像显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中一些图像,我想开始没有图像在他们。我已经设置src =。但是在浏览器中显示破损的图片图片。

I have a table with some images that I want to start out with no images in them.I have set the src="".But when viewed in a browser it shows broken image pics.

<tr>
<td><img src=""> </td>
<td><img src=""> </td>
<td><img src=""></td>
</tr>

如何防止浏览器显示损坏的图像pics或X或任何东西,直到我把一些数据
into the src attribute。

How can I prevent the browser from showing the broken image pics or X or whatever until I put some data into the src attribute.

推荐答案

只要不把那些 img 元素。他们没有语义价值。此外,您应该阅读这篇文章:空图片src可以在NCZOnline上销毁您的网站

我想你用JavaScript改变图片来源。您应该在单元格中添加 img (如果没有)(请参阅 MDC appendChild()page )。

I guess you're changing the image source with Javascript anyways. You should simply add an img in the cell if there is not one yet (see the example in the MDC appendChild() page).

默认情况下图像( style =display:none;),并且只有使用Javascript显示它们,如果他们得到 src ,但你应该做第一个。)

(Another, uglier solution is to hide the images by default (style="display: none;"), and only display them with Javascript if they get an src. But you should do the first one.)

这篇关于如何阻止损坏的图像显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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