How can you make a simple tag like <img src="a.gif">
hidden programmatically using JavaScript?
This question is related to
javascript
html
css
javascript-events
This question is vague, but if you want to make the image with Javascript. It is simple.
function loadImages(src) {
if (document.images) {
img1 = new Image();
img1.src = src;
}
loadImages("image.jpg");
The image will be requested but until you show it it will never be displayed. great for pre loading images you expect to be requests but delaying it until the document is loaded.
You can hide an image using javascript like this:
document.images['imageName'].style.visibility = hidden;
If that isn't what you are after, you need to explain yourself more clearly.
Try setting the style to display=none:
<img src="a.gif" style="display:none">
How about
<img style="display: none;" src="a.gif">
That will disable the display completely, and not leave a placeholder
Source: Stackoverflow.com