JS-如何使用JavaScript删除图片? [英] JS - how to remove image with JavaScript?
本文介绍了JS-如何使用JavaScript删除图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了使用JS删除图片的问题像...这样的代码
I faced a problem as to remove image with JS code like a...
<img src="image.png" id='image_X'>
...
document.getElementById('image_X').src=''
图像保持不变:(所以我的问题是如何用JS删除图像?要更详细...如何动态修改图像src属性值?
Image stays unchanged :( So my question is how to remove image with JS? To be more detailed... How to modify the image src attribute value dynamically?
感谢任何有用的评论
推荐答案
var image_x = document.getElementById('image_X');
image_x.parentNode.removeChild(image_x);
这篇关于JS-如何使用JavaScript删除图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文