How to hide all images using javascript?

I enter JavaScript code on the site for personal use using the Google Chrome extension ... I would like to hide all the images until the page loads ... I have a script to run until something loads, but it seems I can’t get the correct code to hide an array of images ... something like:

function beforeload(){ document.getElementsByTagName('img')[0].style.display = "none" } 

Basically, I want all image tags to add style = "display: none" attributes. how to do it?

+6
source share
3 answers

You need to fixate on them

 var images = document.getElementsByTagName('img'); for (i = 0; i < images.length;i++ ) { images[i].style.display = "none"; } 
+15
source

Amr has a way to do this with javascript. If you add jquery to the page, it takes only one line

 $('img').hide(); 
+4
source

Check it out: http://ncthakur.itgo.com/js09.htm

This is not exactly what you are looking for, but you can use part of it.

It took me 7 seconds to find it on google;)

-2
source

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


All Articles