mootools_使用MooTools或jQuery删除损坏的图像

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.

删除损坏的图像是防止用户在您的网站上看到缺点的一种好方法。

翻译自: https://davidwalsh.name/remove-broken-images

mootools

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值