jquery 处理破图

2019-04-15 16:09发布

$('.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","")可能导致死循环,增加服务损耗。)