ここでjQuery/Javascriptが壊れた画像を置き換える前に言及されたこの問題を見つけました
これが最良の答えでした..私はそれを試してみましたが、うまくいきました
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が発生しました。
どうしたの?