判断本地图片是否存在

 1 $(function(){
 2      //添加判断图片是否存在操作
 3      var nopic="__CDN_PATH_1__/public/kn/Plan/images/base_plan.png";
 4      $("img").each(function(){
 5              var img = $(this);
 6              if(document.all && img.fileSize == -1){
 7                  $(this).attr("src", nopic);
 8              }else{
 9                 //头像不替换
10                 if($(img).width() > 110){
11                     $(img).error(function(){
12                         $(this).attr("src", nopic);
13                     });
14                 }
15              }
16          });
17  });

 

posted @ 2015-05-25 18:34  幻星宇  阅读(819)  评论(0)    收藏  举报