JQUERY 隐藏页面无连接图片

列遍检查网页所有 ,发现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:

  1. JQuery 新闻头条淡入淡出效果
  2. Jquery 获取元素数量 length
  3. Jquery 表格上色插件
  4. Javascript 获取 URL 参数
  5. JQUERY 层-隐藏-显示 效果
此条目发表在 Jquery, 前端技术 分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word