K
K
Kusmich2015-09-30 10:49:11
JavaScript
Kusmich, 2015-09-30 10:49:11

How to modify this check for many pictures, and not for one?

There is a code that checks for the presence of a picture (one). And how to remake to check a lot of pictures?

var img = new Image();
img.src = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Proton-K-Zarya.jpg/800px-Proton-K-Zarya.jpg';
img.onload = function(){alert('картинка существует')};
img.onerror = function(){alert('картинка не существует')};

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Bogdanov, 2015-09-30
@Kusmich

It is not clear how this code checks for the presence of an image. But if you like, then you need to push this code into a for loop, the limiter in which will be the number of images.

S
Sergey Zelensky, 2015-09-30
@SergeyZelensky-Rostov

organize an array of pictures and loop over it to check

L
lincoln9932, 2018-08-03
@lincoln9932

I think an array will do

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question