mootools
A while back I wrote a post called Send Email Notifications for Broken Images Using MooTools AJAX. Looking back on that post, I failed to address the image itself. After some thought I've decided it would be best to remove the broken image from the page all together. Below you'll find how to do so using MooTools or jQuery.
不久前,我写了一篇名为《 使用MooTools AJAX发送破碎图像的电子邮件通知》的文章。 回顾该帖子,我无法解决图片本身。 经过一番思考,我决定最好将所有损坏的图像从页面上一起删除。 您将在下面找到使用MooTools或jQuery的方法。
MooTools JavaScript (The MooTools JavaScript)
$$('img').addEvent('error',function() {
this.dispose();
});
The MooTools way of removing elements from the page is Element.dispose().
从页面上删除元素的MooTools方法是Element.dispose() 。
jQuery JavaScript (The jQuery JavaScript)
$('img').error(function() {
$(this).remove();
});
The jQuery way of removing elements from the page is jQuery.remove().
从页面中删除元素的jQuery方法是jQuery.remove() 。
Removing a broken image is a great way of preventing the user from seeing a shortcoming in your website.
删除损坏的图像是防止用户在您的网站上看到缺点的一种好方法。
mootools