1.写在html标签里 ,onerror
<img src="pic.gif" onerror="javascript:this.src='/noPic.gif';"  />

2.

<img src="pic.gif" onerror=="nofind();"   />
    function nofind(event){
        var img=event.srcElement;
        img.src="http://www.cnblogs.com/sys/common/image/fileoperation/icon/default.gif";
        img.onerror=null; //控制不要一直跳动
    }
3.(常用)// 假如默认图片也加载失败,则变成死循环. 此时可使用one()绑定事件
 $(".discover_list  img").one("error", function(e) {
        $(this).attr("src", "images/default.png");
    });

 


 
                    
            
                

相关文章:

  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
猜你喜欢
  • 2022-12-23
  • 2022-01-11
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
相关资源
相似解决方案