列遍检查网页所有 ,发现SRC属性为空的,将该图片隐藏。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-EN">
<head>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>No display images without src value</title>
</head>
<body>
<script type="text/javascript">
$(function()
{
var pic_len = $("img").length;
var i = 0;
//
for(i=0; i<pic_len; i++){
//alert($("img").eq(i).attr("src"));
if($("img").eq(i).attr("src") == ""){
$("img").eq(i).css({ "display": "none"});
}
}
});
</script>
<img src="" class="imglogo" width="98" height="98" alt="1" />
<img src="http://www.yaoyingying.com/wp-content/gallery/liyugang/thumbs/thumbs_20096171482859913.jpg" class="imglogo" width="100" height="75" alt="2" />
<img src="" class="imglogo" width="98" height="98" alt="3"/>
<img src="http://www.yaoyingying.com/wp-content/gallery/perfectworld//thumbs/thumbs_1104928066f_0.jpg" class="imglogo" width="100" height="75" alt="4" />
</body>
</html>提示:你可以先修改部分代码再运行。
Related posts:
