rizzy
rizzy

Reputation: 162

jQuery Image Array

I need to do an image array for a gallery, The gallery has around 10-20 images I'm just unsure on how to actually make an image array in jQuery.

Any help would be greatly appreciated.

Upvotes: 0

Views: 1107

Answers (2)

abuduba
abuduba

Reputation: 5042

 arrayOfHTMLImageElements =    $('#gallery_container img').get();
 orJqueryCollectionOfImages = $('#gallery_container img');
 arraySourcesOfImages =   $('#gallery_container img').map( function(){ return this.src })

Upvotes: 1

Dhaivat Pandya
Dhaivat Pandya

Reputation: 6536

Put the images in <div class="some_img">, and then:

var m = []
$('.some_img').each(function() { m.push ($(this));});

Don't actually use that code; format it first, but, that's the general idea.

Upvotes: 0

Related Questions