K
K
Kusmich2015-10-28 00:08:23
JavaScript
Kusmich, 2015-10-28 00:08:23

How to collect html objects by the number of array elements?

There is an array of url-locs. It is necessary to collect img tags by the number of urls in the array. The img tag must contain the "tableBanner1" class.

Here's an array for example:

var masive_picture  =    ["https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Proton-K-Zarya.jpg/800px-Proton-K-Zarya.jpg", "https://upload.wikimedia.org/wikipedia/ru/3/31/Winniethepooh.jpg" ]


<img class="tableBanner1"  src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Proton-K-Zarya.jpg/800px-Proton-K-Zarya.jpg" />
<img class="tableBanner1"  src="https://upload.wikimedia.org/wikipedia/ru/3/31/Winniethepooh.jpg" />

Знаю что нужно пройтись по массиву цыклом но не знаю как это должно выглядить синтаксически. Подскажите кто знает как это сделать ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-10-28
@Kusmich

jquerybook.ru/api/jQuery.each()-fn58.html

jQuery.each(masive_picture, function(i, val) {
      $("div").append('<img class="tableBanner1"  src="'+val+'" '/>
);
     });

Well, something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question