我发现以前这里jQuery/Javascript to replace broken imagesjQuery的执行,当图像被打破
提到了这个问题,这是最好的答案的事件。我尝试过了,它的正常工作
function ImgError(source){
source.src = "/images/noimage.gif";
source.onerror = "";
return true;
}
<img src="someimage.png" onerror="ImgError(this);"/>
但是当我试图瓶坯其他事件在以前的功能
function ImgError(source){
source.hide(); // hide instead of replacing the image
source.onerror = "";
return true;
}
我得到这个错误
TypeError: 'undefined' is not a function (evaluating 'source.hide()')
每一个jQuery事件/方法我试过这个函数我得到了一个TypeError。
有什么问题?
您没有使用jQuery。 – SLaks 2012-07-25 22:05:14