$('.pic img').on("error", function (e) {
//方法1:
if (window.imgerrcount == undefined) {
$(this).attr("src", "/images/wutu.jpg");
window.imgerrcount = 1;
}
return true;
//方法2:
//$(this).replaceWith("
");
});
(不会导致死循环,增加服务损耗。直接用$(this).attr("src","
")可能导致死循环,增加服务损耗。)