JQUERY 隐藏页面无连接图片

Google AD

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

提示:你可以先修改部分代码再运行。

相关文章

  1. JQuery 新闻头条淡入淡出效果
  2. Jquery 获取元素数量 length
  3. Jquery 表格上色插件
  4. JQUERY 层-隐藏-显示 效果
  5. Javascript 获取 URL 参数

Google Ad

Leave a Reply

*
请输入图片中的字符以验证你并非垃圾机器人. 点击图片收听验证码的语音版.
点击这里收听此验证码的语音版本


Google AD

关于站长

姚迎迎,生于 1985年3月2日, 江苏大丰人士 。修行于福州大学软件学院

Google 广告

最近文章