hidden programmatically using JavaScript? +3 ...">

How to create a hidden <img> in JavaScript?

How to make a simple type tag <img src="a.gif">hidden programmatically using JavaScript?

+3
source share
5 answers

I'm not sure I understand your question. But there are two approaches to making the image invisible ...

Pure html

<img src="a.gif" style="display: none;" />

Or...

HTML + Javascript

<script type="text/javascript">
document.getElementById("myImage").style.display = "none";
</script>

<img id="myImage" src="a.gif" />
+39
source

What about

<img style="display: none;" src="a.gif">

This will completely disable the display and leave no placeholder.

+3
source

javascript :

document.images['imageName'].style.visibility = hidden;

, , .

+3

, Javascript. .

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 preloading the images that you expect from requests but delaying them until the document is loaded.

Example

+3
source

Try setting the style to display = none:

<img src="a.gif" style="display:none">
+2
source

Source: https://habr.com/ru/post/1710487/


All Articles