判断本地图片是否存在

 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  });
原文地址:https://www.cnblogs.com/xingmeng/p/4528586.html