使用jQuery清除IMG [英] Clear an IMG with jQuery

查看:621
本文介绍了使用jQuery清除IMG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从<img>元素中删除已加载的图像,但是清除或删除src并不会这样做.该怎么办?

I'm trying to remove the loaded image from a <img> element, but clearing or removing the src doesn't do it. What to do?

HTML:

<img src='https://www.google.com/images/srpr/logo3w.png'>

JQUERY:

$('img').attr('src', ''); // Clear the src
$('img').removeAttr('src');​ // Remove the src

图像仍然存在...

小提琴: http://jsfiddle.net/6x9NZ/

推荐答案

您将必须删除完全<img>元素,或将其替换为其他图像(可以是透明gif).

You would have to either remove the <img> element entirely or replace it with a different image (which could be a transparent gif).

这篇关于使用jQuery清除IMG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆