html图片无法显示或出错

1.<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"); });

猜你喜欢

转载自www.cnblogs.com/yuesu/p/9282804.html
今日推荐